📜  使用C ++的ATM管理系统

📅  最后修改于: 2021-06-01 02:00:04             🧑  作者: Mango

自动取款机是用来携带一天到一天的金融交易自动柜员机。自动柜员机可用于取款,存款或什至了解帐户信息(如余额等)。它们既方便又易于使用,它使消费者可以进行快速的自助交易。

在本文中,我们将讨论C++中的ATM管理系统,它是一个为用户提供实际自动柜员机(即ATM)应具备的各个方面的应用程序。它是具有ATM功能的菜单驱动程序,其中包括:

方法:该程序使用类的基本概念,C++中的访问修饰符,数据类型,变量,切换用例等。下面是要实现的功能:

  • setvalue()此函数用于在C++中使用基本的输入和输出方法(即cout和cin语句)设置数据,这些语句显示并分别从键盘(即从用户)获取和获取输入。
  • showvalue ():此函数用于打印数据。
  • deposit():此函数有助于将钱存入特定帐户。
  • showbal( ):此函数显示沉积后可用的总平衡。
  • withdrawl(): 此函数有助于从帐户中提取资金。
  • main()此函数在无限的while循环内有一个简单的切换条件(做出选择) 以便每次用户选择选择时。

以下是使用上述方法的C++程序:

C++
// C++ program to implement the ATM
// Management System
#include 
#include 
#include 
using namespace std;
class Bank {
  
    // Private variables used inside class
private:
    string name;
    int accnumber;
    char type[10];
    int amount = 0;
    int tot = 0;
  
    // Public variables
public:
    // Function to set the person's data
    void setvalue()
    {
        cout << "Enter name\n";
        cin.ignore();
  
        // To use space in string
        getline(cin, name);
  
        cout << "Enter Account number\n";
        cin >> accnumber;
        cout << "Enter Account type\n";
        cin >> type;
        cout << "Enter Balance\n";
        cin >> tot;
    }
  
    // Function to display the required data
    void showdata()
    {
        cout << "Name:" << name << endl;
        cout << "Account No:" << accnumber << endl;
        cout << "Account type:" << type << endl;
        cout << "Balance:" << tot << endl;
    }
  
    // Function to deposit the amount in ATM
    void deposit()
    {
        cout << "\nEnter amount to be Deposited\n";
        cin >> amount;
    }
  
    // Function to show the balance amount
    void showbal()
    {
        tot = tot + amount;
        cout << "\nTotal balance is: " << tot;
    }
  
    // Function to withdraw the amount in ATM
    void withdrawl()
    {
        int a, avai_balance;
        cout << "Enter amount to withdraw\n";
        cin >> a;
        avai_balance = tot - a;
        cout << "Available Balance is" << avai_balance;
    }
};
  
// Driver Code
int main()
{
    // Object of class
    Bank b;
  
    int choice;
  
    // Infinte while loop to choose
    // options everytime
    while (1) {
        cout << "\n~~~~~~~~~~~~~~~~~~~~~~~~~~"
             << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
             << "~~~WELCOME~~~~~~~~~~~~~~~~~~"
             << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
             << "~~~~~~~~~\n\n";
        cout << "Enter Your Choice\n";
        cout << "\t1. Enter name, Account "
             << "number, Account type\n";
        cout << "\t2. Balance Enquiry\n";
        cout << "\t3. Deposit Money\n";
        cout << "\t4. Show Total balance\n";
        cout << "\t5. Withdraw Money\n";
        cout << "\t6. Cancel\n";
        cin >> choice;
  
        // Choices to select from
        switch (choice) {
        case 1:
            b.setvalue();
            break;
        case 2:
            b.showdata();
            break;
        case 3:
            b.deposit();
            break;
        case 4:
            b.showbal();
            break;
        case 5:
            b.withdrawl();
            break;
        case 6:
            exit(1);
            break;
        default:
            cout << "\nInvalid choice\n";
        }
    }
}


输出:

  • 显示选择:
  • 对于选择1:
  • 对于选择3:
  • 对于选择2:
  • 对于选择5:
想要从精选的最佳视频中学习并解决问题,请查看有关从基础到高级C++的C++基础课程以及有关语言和STL的C++ STL课程。要完成从学习语言到DS Algo等的更多准备工作,请参阅“完整面试准备课程”