当前位置: 首页>>代码示例>>C++>>正文


C++ BankAccount::SetDollars方法代码示例

本文整理汇总了C++中BankAccount::SetDollars方法的典型用法代码示例。如果您正苦于以下问题:C++ BankAccount::SetDollars方法的具体用法?C++ BankAccount::SetDollars怎么用?C++ BankAccount::SetDollars使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BankAccount的用法示例。


在下文中一共展示了BankAccount::SetDollars方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: atm

int atm()
{
    CinReader reader;
    BankAccount myBanking;
    bool end_program = false;
    bool done = false;
    long dollars;
    int cents;
    do
    {
        cout << "Select the type of account you wish to create" << endl;
        cout << "1 Bank Account 2 - Checking 3 - Savings 4 - Credit\n" << endl;
        int choice = reader.readInt(1,4);
        string account_name;
        long balance_dollars;
        int balance_cents;
        double interest_rate;
        switch(choice)
        { 
            //Bank account options
            case 1:
            {
                cout << "Set the dollar amount of your account balance\n" << endl;
                balance_dollars = reader.readInt(0);
                cout << "Set the cent amount of your account balance\n" << endl;
                balance_cents = reader.readInt(0,99);
                myBanking.SetDollars(balance_dollars);
                myBanking.SetCents(balance_cents);
                cout << "Please select from the following options." << endl;
                while(!done)
                {
                    cout << "1 - Show account balance\n2 - Deposit\n3 - Withdraw\n4 - Show recent transactions\n5 - Clear Transaction history\n6 - Exit ATM\n" << endl;
                    int choice = reader.readInt(1,6);
                    switch(choice)
                    {
                        case 1:
                        {
                            cout << myBanking.ShowBalance() << endl;
                        break;
                        }
                        
                        case 2:
                        {
                            cout << "Please enter the amount in dollars you would like to deposit, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myBanking.DepositAccount(dollars, cents);
                        break;
                        }
                        
                        case 3:
                        {
                            cout << "Please enter the amount in dollars you would like to withdraw, followed by the amount in cents\n" << endl;
                            dollars = reader.readInt(0);
                            cents = reader.readInt(0,99);
                            myBanking.WithdrawAccount(dollars, cents);
                        break;
                        }
                        
                        case 4:
                        {
                            for(int i = 0;i<10;i++)
                            {
                                if(myBanking.GetRecentTransactions(i) == "")
                                {
                                    cout << "none" << endl;
                                }else
                                {
                                cout << myBanking.GetRecentTransactions(i) << endl;
                                }
                            }
                            
                            cout << "Your last transaction was: " << myBanking.GetLastTransaction() << endl;
                        break;
                        }
                        
                        case 5:
                        {
                            myBanking.ClearRecentTransactions();
                        break;
                        }
                        
                        case 6:
                        {
                            done = true;
                        }
                    }
                }
            break;
            }
            
            //Checking account options
            case 2:
            {
                CheckingAccount myChecking;
                cout << "Set the dollar amount of your account balance" << endl;
                balance_dollars = reader.readInt(0);
                cout << "Set the cent amount of your account balance\n" << endl;
                balance_cents = reader.readInt(0,99);
                myChecking.SetDollars(balance_dollars);
//.........这里部分代码省略.........
开发者ID:ddalton002,项目名称:ddalton002stuff,代码行数:101,代码来源:atm.cpp


注:本文中的BankAccount::SetDollars方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。