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 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202
|
#include <iostream>
using namespace std; //introduces namespace std
class Account
{
private:
int acctNumber;
string acctName;
double acctBal;
public:
// 2 constructors
Account ()
{
acctNumber=0;
acctName=" ";
acctBal=0;
}
Account (int a,string ac,double acc)
{
acctNumber=a;
acctName = ac;
acctBal = acc;
}
// sets
void setNum(int a)
{
acctNumber = a;
}
void setName(string ac)
{
acctName = ac;
}
void setBal(double acc)
{
acctBal = acc;
}
// gets
int getAccNum()
{
return acctNumber;
}
string getName()
{
return acctName;
}
double getBal()
{
return acctBal;
}
};// end class
int main()
{
int choice;
string name = " ";
int accNum=0;
int acctBal=0;
double bal=0;
int choice2;
int choice3;
float depo;
float with;
int i =0;
const int SIZE = 15;
Account bank[SIZE]= {Account (12345, "Smith", 1005.99),
Account (19822, "Lee", 20.21),
Account (18521, "Kim", 3061.77),
Account (85218, "Wall", 9855.33),
Account (85199, "Harry", 9077.88),
Account (91532, "Jess", 63112.99),
Account (43174, "Glee", 641.88),
Account (63173, "Corr", 841.55),
Account (23441, "Matt", 124.92),
Account (65185, "Card", 90.22),
Account (62188, "Kells", 529.77),
Account (32188, "Slyth", 863.22),
Account (90888, "Booth", 7422.88),
Account (52111, "Good", 321.99),
Account (87331, "Williams", 7317.21)};
cout <<"\tWelcome to Bank!";
cout <<"\n\tYou can make a deposit or withdraw ";
cout <<"\n\n\tPlease have your account number";
cout <<"\n\tor the name on the account ready\n";
// all of your code here
cout << "Do you want to check account balance by name or account number?";
cout << endl;
cout << "1-Name";
cout << endl;
cout << "2-Account Number";
cout << endl;
cout << "3-Exit";
cout << endl;
cin >> choice;
if (choice == 1)
{
cout << "Enter your account name: ";
cin >> name;
for(i=0; i<15; i++)
{
if(bank[i].getName() == name)
{
cout<<"Account Number: " << bank[i].getAccNum()<<endl;
cout<<"Account Name: " <<bank[i].getName()<<endl;
cout<<"Account Balance: "<<bank[i].getBal()<<endl;
cout << endl;
}
}
cout << "Do you want to withdraw or deposit?"<<endl;
cout << "1=Deposit"<<endl;
cout << "2=Withdraw"<<endl;
cin >> choice2;
if (choice2==1)
{
cout << "How much would you like to deposit?: ";
cin >> depo;
for (i=0;i<15;i++)
{
if(bank[i].getName() == name)
{
cout << "You have "<<bank[i].getBal()+depo<<" as a balance now."<<endl;
}
}
}
if (choice2==2)
{
cout << "How much would you like to withdraw?";
cin >> with;
for (i=0;i<15;i++)
{
if(bank[i].getName() == name)
{
cout << "You have "<<bank[i].getBal()-with<<" as a balance now."<<endl;
}
}
}
}
if (choice == 2)
{
cout << "Enter your account number: ";
cin >> accNum;
for(i=0; i<15; i++)
{
if(bank[i].getAccNum() == accNum)
{
cout<<"Account Number: " << bank[i].getAccNum()<<endl;
cout<<"Account Name: " <<bank[i].getName()<<endl;
cout<<"Account Balance: "<<bank[i].getBal()<<endl;
cout << endl;
}
}
{
cout << "Do you want to withdraw or deposit?"<<endl;
cout << "1=Deposit"<<endl;
cout << "2=Withdraw"<<endl;
cout << "3=Exit"<<endl;
cin >> choice2;
if (choice2==1)
{
cout << "How much would you like to deposit?: ";
cin >> depo;
for (i=0;i<15;i++)
{
if(bank[i].getAccNum() == accNum)
{
cout << "You have "<<bank[i].getBal()+depo<<" as a balance now."<<endl;
}
}
}
if (choice2==2)
{
cout << "How much would you like to withdraw?";
cin >> with;
for (i=0;i<15;i++)
{
if(bank[i].getAccNum() == accNum)
{
cout << "You have "<<bank[i].getBal()<<" as a balance now."<<endl;
}
}
}
}
}
cout <<"Good Bye";
return 0;
}
|