Is this code right or am I missing something ? id» initialBalanceSavings "savingAccountsavingiccount-setInterest(annualinterestRate);savingaccount-setMinbalance(ninimunalance);accounts...

Is this code right or am I missing something ?
Savang saV nterest(annuallnterestRate);<br>(to antsetBalance(intialalance):<br>1Sop<br>Run Detug<br>MSae<br>men op<br>9include dostrean<br>include cfstrean<br>3 includecstring<br>4 using nanespace std;<br>class Account(<br>int id;<br>double balance;<br>publies<br>r<br>20<br>Account ()(<br>id-<br>balance =e.e;<br>21<br>12<br>14<br>Account (int newID, double initialBalance){<br>id- newlD;<br>balance-initial8alance;<br>15<br>16<br>17<br>18<br>29<br>20<br>21<br>veid setI0(int newID){<br>id newID;<br>void settalance(double initialBalance){<br>balance initialalance,<br>23<br>24<br>25<br>int getID()<br>return id;<br>26<br>27<br>28<br>29<br>double getsalance(){<br>return balance;<br>30<br>31<br>void withdraw(double amount){<br>balance - balance- ount;<br>32<br>33<br>34<br>35<br>void deposit(double anount){<br>balance balance mount,<br>36<br>37<br>38<br>virtual void closetonth()-e<br>39<br>virtual string accountstring()-<br>41<br>42<br>43 );<br>44 elass Savings:publie Account{<br>double interest;<br>double minbalance;<br>public:<br>Savings()<br>46<br>47<br>48<br>49<br>se<br>void eloselonth(){<br>double pre- getsalance();<br>52<br>53<br>double newdalance- pre ((pre (interest/100.0))/12.0):<br>54<br>55<br>setBalance(newBalance);<br>56<br>string accountstring()<br>57<br>+ to_string(getID()) has balance of S
id» initialBalance Savings "savingAccount savingiccount-setInterest(annualinterestRate); savingaccount-setMinbalance(ninimunalance); accounts (totalAccount) savingaccount: accounts[totalAccount]-setID(id); accounts(totalAccount]-setBalance(initialBalance); tetalAccount- cout "Saving account nunber "cctotalAccount « created" id» initial8alance inimunalance >> monthlyfees: Checking "checkingaccount- new Checking(): checkingAccount-setMonthlyFee(monthlyFees); checkingiccount-setkinBalance(mininunBalance); accounts[totalAccount]- checkingAccount; accounts(totalAccount)-setiD(id); accounts[totalAccount]setBalance(initialBalance); tetalAccount cout "Checking account nunber "cctotalAccount «* created"
Extracted text: Savang saV nterest(annuallnterestRate); (to antsetBalance(intialalance): 1Sop Run Detug MSae men op 9include dostrean include cfstrean 3 includecstring 4 using nanespace std; class Account( int id; double balance; publies r 20 Account ()( id- balance =e.e; 21 12 14 Account (int newID, double initialBalance){ id- newlD; balance-initial8alance; 15 16 17 18 29 20 21 veid setI0(int newID){ id newID; void settalance(double initialBalance){ balance initialalance, 23 24 25 int getID() return id; 26 27 28 29 double getsalance(){ return balance; 30 31 void withdraw(double amount){ balance - balance- ount; 32 33 34 35 void deposit(double anount){ balance balance mount, 36 37 38 virtual void closetonth()-e 39 virtual string accountstring()- 41 42 43 ); 44 elass Savings:publie Account{ double interest; double minbalance; public: Savings() 46 47 48 49 se void eloselonth(){ double pre- getsalance(); 52 53 double newdalance- pre ((pre (interest/100.0))/12.0): 54 55 setBalance(newBalance); 56 string accountstring() 57 + to_string(getID()) has balance of S"ito_string(getsalance()); 59 return "SavingE account 61 void setInterest(double interest){ this-interest-interest; 62 63 64 void setMintalance(double minlalance)( this-mintalance minsalance; 65 66 69- class Checking public Account( double mintalance; double monthlyree; 71 72 public: 73 Checking(){ 74 75 void closelonth() double nelalance getsalance() setalance(newalance); 76 77 78 79 monthlyfee, string accountstring() 81- return "Checking account + to string(getID()) +" has balance of $"-to_string(gettalance()); 82 83 84 85 void setMonthlyFee(double monthlyFee){ this-nonthlyfee nonthlyfee; 86 87 void setMinlalance(double minialance){ this-minalance = minsalance; 88 89 91 92 ); 93 94 int nainO{ 95 Accountaccounts = new Account [10]; ifstrean infile; infile.open("bank2.txt"); 1n länfile ) cerr « "File cannont be opened" <« endl;="" else="" cout="" e="" "file="" opened"endl;="" string="" operationtype;="" int="" tetalaccount="" 96="" 97="" 98="" 99="" 100="" 101="" 102="" 103="" while(infileoperationtype)="" 104="" 105="" 106="" 107="" if(operationtype="" "savings"h="" int="" id;="" double="" initialbalance,minimunbalance,="" annualinterestrate;="" infile=""> id» initialBalance Savings "savingAccount savingiccount-setInterest(annualinterestRate); savingaccount-setMinbalance(ninimunalance); accounts (totalAccount) savingaccount: accounts[totalAccount]-setID(id); accounts(totalAccount]-setBalance(initialBalance); tetalAccount- cout "Saving account nunber "cctotalAccount « created" id» initial8alance inimunalance >> monthlyfees: Checking "checkingaccount- new Checking(): checkingAccount-setMonthlyFee(monthlyFees); checkingiccount-setkinBalance(mininunBalance); accounts[totalAccount]- checkingAccount; accounts(totalAccount)-setiD(id); accounts[totalAccount]setBalance(initialBalance); tetalAccount cout "Checking account nunber "cctotalAccount «* created"
coutewith an initial balance of S> id > anount; for(int i-e;i totalAccount;i++){ if (accounts[i]-getID()--id){ 136 137 138 139 148 141 142 143 isFound-true; accounts [i]->deposit(amount); pos-i; 144 145 146 147 148 if(lisFound){ cout"Invalid Account Number - "<"current balance="" is=""><>> id >> anount; bool isFound-false; for(int i-e;itotalAccount;i+){ if (accounts[i]-getID()--id){ 157 158 159 160 161 162 163 164 165 isFound-true; accounts (i]-withdraw(amount); pos i; 166 167 168 169 178 171 ir(lisFound){ coutce"Invalid Account Number - "ccidccendl; 172 173 elsef cout ccwithdraw $"ccamount c" from account recidccendl; coute"current balance is S"caccounts[pos]-getBalance()< cendl;="" 174="" 176="" 177="" else="" if="" (operationtype="" "balance"){="" int="" id;="" infile="">» id; int pos; 178 179 180 181 bool isFound-false; for (int i-e;ictotalAccount;i){ if (accounts[i]->getID()=-id){ isFound true; 182 184 185 cout"Current balance in account "ccid e" is S"caccounts[i] getBalance()closeMonth(); 195 196 197 198 199 else if (operationType "Report"){ for (int i-e;itotalAccount;i+){ cout « accounts[i]->accountString() « endl; 200 201 202 203 204 elsef coute"Unrecognised command string dunnyline; getline(infile, dumnyline); 205 "ccoperationTypeccendl; 208 afile.close(); 213 Input Wan t "/>
Extracted text: coutewith an initial balance of S"caccounts[totalAccount-1]-getBalance()> id > anount; for(int i-e;i totalAccount;i++){ if (accounts[i]-getID()--id){ 136 137 138 139 148 141 142 143 isFound-true; accounts [i]->deposit(amount); pos-i; 144 145 146 147 148 if(lisFound){ cout"Invalid Account Number - "<"current balance="" is=""><>> id >> anount; bool isFound-false; for(int i-e;itotalAccount;i+){ if (accounts[i]-getID()--id){ 157 158 159 160 161 162 163 164 165 isFound-true; accounts (i]-withdraw(amount); pos i; 166 167 168 169 178 171 ir(lisFound){ coutce"Invalid Account Number - "ccidccendl; 172 173 elsef cout ccwithdraw $"ccamount c" from account recidccendl; coute"current balance is S"caccounts[pos]-getBalance()< cendl;="" 174="" 176="" 177="" else="" if="" (operationtype="" "balance"){="" int="" id;="" infile="">» id; int pos; 178 179 180 181 bool isFound-false; for (int i-e;ictotalAccount;i){ if (accounts[i]->getID()=-id){ isFound true; 182 184 185 cout"Current balance in account "ccid e" is S"caccounts[i] getBalance()closeMonth(); 195 196 197 198 199 else if (operationType "Report"){ for (int i-e;itotalAccount;i+){ cout « accounts[i]->accountString() « endl; 200 201 202 203 204 elsef coute"Unrecognised command string dunnyline; getline(infile, dumnyline); 205 "ccoperationTypeccendl; 208 afile.close(); 213 Input Wan t
Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here