Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.30 KB | None | 0 0
  1. int main()
  2. {
  3.     //create two Account objects
  4.     Account account1{ "Jane Green", 75 };
  5.     Account account2{ "John blue", -7 };
  6.     Account account3{ "Chippy", 1000 };
  7.  
  8.     cout << "\n\nAccount1 name is: " << account1.getName();
  9.     cout << "\nbalance is $" << account1.getBalance();
  10.     cout << "\nAccount2 name is: " << account2.getName();
  11.     cout << "\nbalance is $" << account2.getBalance();
  12.     cout << "\nAccount3 name is:" << account3.getName();
  13.     cout << "\nbalance is $" << account3.getBalance();
  14.  
  15.  
  16.     cout << "\n\nEnter deposit amount for account1: "; //prompt dont need int Deposit amount again
  17.     int depositAmount;
  18.     cin >> depositAmount; //obtain input
  19.     cout << "adding" << depositAmount << "too account1 balance" << endl;
  20.     account1.deposit(depositAmount); // add to account 1's balance
  21.  
  22.  
  23.  
  24.     //withdrawing
  25.     int withdrawlAmount;
  26.     cout << "\nEnter a withdrawl amount for account1: ";
  27.     cin >> withdrawlAmount;
  28.     if (withdrawlAmount > depositAmount) {
  29.         cout << "Not enough funds" << endl;
  30.     }
  31.     else {
  32.         cout << "withdrawing " << withdrawlAmount << "from account 1";
  33.         account1.withdrawl(withdrawlAmount); // add to account 1's balance
  34.  
  35.     }
  36.  
  37. //disply balances
  38.  
  39.  
  40.     cout << "\n\nAccount1 name is: " << account1.getName();
  41.     cout << "\nbalance is $" << account1.getBalance();
  42.     cout << "\nAccount2 name is: " << account2.getName();
  43.     cout << "\nbalance is $" << account2.getBalance();
  44.     cout << "\nAccount3 name is:" << account3.getName();
  45.     cout << "\nbalance is $" << account3.getBalance();
  46.  
  47.  
  48.  
  49.     cout << "\n\nEnter deposit amount for account2: "; //prompt
  50.     //dont need twice
  51.     cin >> depositAmount; //obtain input
  52.     cout << "adding" << depositAmount << "too account2 balance";
  53.     account2.deposit(depositAmount); // add to account 1's balance
  54.  
  55.  
  56.     cout << "\nEnter a withdrawl amount for account2: ";
  57.     cin >> withdrawlAmount;
  58.     if (withdrawlAmount > depositAmount) {
  59.         cout << "Not enough funds" << endl;
  60.     }
  61.     else {
  62.         cout << "withdrawing " << withdrawlAmount << "from account 2";
  63.         account2.withdrawl(withdrawlAmount); // add to account 1's balance
  64.     }
  65.  
  66.  
  67.                                      //disply balances
  68.     cout << "\n\nAccount1 name is: " << account1.getName();
  69.     cout << "balance is $" << account1.getBalance();
  70.     cout << "\nAccount2 name is: " << account2.getName();
  71.     cout << "balance is $" << account2.getBalance();
  72.     cout << "\nAccount3 name is:" << account3.getName();
  73.     cout << "balance is $" << account3.getBalance();
  74.  
  75.     cout << "\n\nEnter deposit amount for account: "; //prompt
  76.     cin >> depositAmount; //obtain input
  77.     cout << "adding" << depositAmount << "too account3 balance";
  78.     account3.deposit(depositAmount); // add to account 1's balance
  79.  
  80.  
  81.     cout << "\nEnter a withdrawl amount for account3: ";
  82.     cin >> withdrawlAmount;
  83.     if (withdrawlAmount > depositAmount) {
  84.         cout << "Not enough funds" << endl;
  85.     }
  86.     else {
  87.         cout << "withdrawing " << withdrawlAmount << "from account 3";
  88.         account3.withdrawl(withdrawlAmount); // add to account 1's balance
  89.     }
  90.  
  91.                                      //disply balances
  92.     cout << "\n\nAccount1 name is: " << account1.getName();
  93.     cout << "balance is $" << account1.getBalance();
  94.     cout << "\nAccount2 name is: " << account2.getName();
  95.     cout << "balance is $" << account2.getBalance();
  96.     cout << "\nAccount3 name is:" << account3.getName();
  97.     cout << "balance is $" << account3.getBalance() << endl;
  98.  
  99.     system("pause");
  100.     return 0;
  101. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement