It should display/out these results
1. Use “prompts” so that the user knows what to expect, what to do, and how to do it. For example:
Enter withdrawal amount for Account Number 123:
2. The program should display the output on the screen. The output should look like the following (the numbers in bold are typed by the user):
Account number: 123 Balance: $50.00
Account number: 456 Balance: $25.00
Enter withdrawal amount for Account Number 123: 35.00
Attempting to subtract $35.00 from Account Number 123’s balance.
Account Number 123’s balance: $15.00
Account Number 456’s balance: $25.00
Enter withdrawal amount for Account Number 456: 50.00
Attempting to subtract $50.00 from Account Number 456’s balance.
Debit amount exceeded account balance – this withdrawal was canceled.
Account Number 123’s balance: $15.00
Account Number 456’s balance: $25.00
Enter deposit amount for Account Number 123: 100.00
Account Number 123’s balance: $115.00
Account Number 456’s balance: $25.00
Enter deposit amount for Account Number 456: 50.00
Account Number 123’s balance: $115.00
Account Number 456’s balance: $75.00
And this is what I have coded/changed or taken help code. Please help me where I am making mistake?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147
|
#include <iostream>
#include "stdxfh
using namespace std; //introduces namespace std
class Account
{
private:
int acctNumber;
double acctBal;
public:
// 2 constructors
Account ()
{
acctNumber=0;
acctBal=0;
}
Account (int a,string ac,double acc)
{
acctNumber=a;
acctBal = acc;
}
// sets
void setNum(int a)
{
acctNumber = a;
}
void setBal(double acc)
{
acctBal = acc;
}
// gets
int getAccNum()
{
return acctNumber;
}
double getBal()
{
return acctBal;
}
};// end class
int main()
{
int choice;
int accNum=0;
int acctBal=0;
double bal=0;
int choice2;
int choice3;
float depo;
float with;
int i =0;
const int SIZE = 2;
Account bank[SIZE]= {Account (123, 50.00),
Account (456, 25.00)};
cout <<"\tWelcome to Bank!";
cout <<"\n\tYou can make a deposit or withdraw ";
cout <<"\n\n\tPlease have your account number";
cout << "Do you want to check account balance by account number?";
cout << endl;
cout << "1-Account Number";
cout << endl;
cout << "2-Exit";
cout << endl;
cin >> choice;
if (choice == 1)
{
cout << "Enter your account number: ";
cin >> accNum;
for(i=0; i<2; i++)
{
if(bank[i].getAccNum() == accNum)
{
cout<<"Account Number: " << bank[i].getAccNum()<<endl;
cout<<"Account Balance: "<<bank[i].getBal()<<endl;
cout << endl;
}
}
{
cout << "Do you want to withdraw, deposit, check balance or get account number?"<<endl;
cout << "1=Deposit"<<endl;
cout << "2=Withdraw"<<endl;
cout << "3=Balance"<<endl;
cout << "4=Account Information"<<endl;
cout << "5=Exit"<<endl;
cin >> choice2;
if (choice2==1)
{
cout << "How much would you like to deposit?: ";
cin >> depo;
for (i=0;i<2;i++)
{
if(bank[i].getAccNum() == accNum)
{
cout << "You have "<<bank[i].getBal()+depo<<" as a balance now."<<endl;
}
}
}
if (choice2==2)
{
do {
cout << "How much would you like to withdraw?";
cin >> with;
} while (with <= 0); // Stop Negatives
for (i=0;i<2;i++) {
if(bank[i].getAccNum() == accNum) {
if (bank[i].getBal() > with) {
cout <<"Attempting to subtract"<<bank[i].with<<" from Account Number "<<bank[i]<<"'s balance."<<endl;
cout << "Debit amount exceeded account balance - this withdrawal was cancelled." <<endl;
cout <<"Account Number"<<bank[i]<<"'s balance: "<<bank[i].getBal()<<""<<endl;
} else {
// Do Withdrawal
}
cout <<"Attempting to subtract"<<bank[i].with<<" from Account Number "<<bank[i]<<"'s balance."<<endl;
cout <<"Account Number"<<bank[i]<<"'s balance: "<<bank[i].getBal()<<""<<endl;
}
}
}
if (choice2==3)
{
cout <<"Account Number:"<<bank[i]<<" Balance: "<<bank[i].getBal()<<""<<endl;
}
if (choice2==4)
{
cout <<"Your Account Number is:"<<bank[i]<<" and Balance is: "<<bank[i].getBal()<<""<<endl;
}
if (choice2==5)
{
cout <<"Good Bye";
}
return 0;
}
|