This does not handle the end of month processing correctly. The monthly fee should only be deducted if the balance is below the minimum. Similarly, the interest should only be added if the balance is above the minimum. What does this mean and below is my code and this is a c++ assignment not a Java problem

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
This does not handle the end of month processing correctly. The monthly fee should only be deducted if the balance is below the minimum. Similarly, the interest should only be added if the balance is above the minimum. What does this mean and below is my code and this is a c++ assignment not a Java problem
(to an setBalance(initialalance);
MSa
Run Detg
1Skop
hre
ba
Minclude ciostream
mn op te
VinCiude cfstrean
3 includecstring
4 using namespace std;
class Account{
int id;
double balance
publies
20
Account (){
id-
balance =e.e;
11
12
10
14
15
Account (int newID, double initialBalance){
id newlD;
balance-initialBalance;
16
17
18
19
20
21
veid setID(int newID){
id newID;
void settalance(double initialBalance){
balance initialalance;
23
24
int getID()
return id;
25
26
27
28
29
deuble getsalance(){
return balance;
30
31
32
veid withdraw(double amount){
balance balance amount;
33
34
35
void deposit(double amount){
balance balance mount:
36
37
38
virtual void closetonth()-e
39
virtual string accountstring()-
41
42
43 );
44 elass Savings:public Account(
double interest;
double minbalance;
public:
Savings()
46
47
48
49
void eloselonth(){
double pre- getalance();
51
52
53
double newialance - pre ((pre (interest/100.0))/12.0);
54
55
setBalance(newalance);
56
string accountstring()
57
59
return "Saving account + to_string(getID()) has balance of S"ito_string(getsalance());
61
62
63
void setInterest(double interest){
this-interest-interest;
void settintalance(double minBalance){
this-mintalance minsalance;
65
66
68 );
69 - class Checking public Account(
double minialance;
double monthlyFee;
71
72 public:
73
Checking(){
74
75
void closehonth()
double nelalance getlalance()
settalance(newalance);
76
77
78
monthlyfee;
string accountstring()
81
return "Checking account+ to_string(getID()) +* has balance of s"-to_string(getBalance());
82
83
84
void setMonthlyFee(double monthlyFee){
this- nonthlyfee nonthlyfee;
85
86
87
88
void setkinlalance(double minlalance){
this-minalance = minsalance;
89
91
92 ):
93
94- int nainO{
95
Account accounts = new Account [10];
ifstrean infile;
infile.open("bank2.txt"):
if( infile )
cerr « "File cannont be opened" <« endl;
else
cout e "File Opened"<cendl;
string operationType;
int totalAccount-e;
while(infileoperationType)
96
97
98
99
100
101
102
103
104
105
106
107
if(operationtype "Savings"H
int id;
double initialBalance,minimundalance, annualInterestRate;
infile » id > initialBalance
Savings "savingAccount- new Savings();
savingkccount-setInterest(annualInterestRate);
savingaccount-setMinbalance(minimunalance);
accounts(totalAccount] = savingaccount;
accounts[totalAccount]-setID(id);
accounts(totalAccount]-setBalance(initialBalance);
tetalAccount;
cout ce"Saving account nunber "cctotalAccount created"<endl;
cout"with an initial balance of saccounts[totalAccount-1]-getBalance()cendi;
108
> ninimunsalance> annualInterestRate;
109
11e
111
112
113
114
115
116
117
118
119
12e
121
122
123
124
125
else if(operationType "Checking )
int id;
double initialBalance,minimunbalance, nonthlyFees;
infile » id > initialBalance >> ninimunsalance > 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 number "cctotalAccount « created"<cendl;
cout"with an initial balance of S"accounts[totalAccount-1]-getBalance()cendl;
126
127
128
129
130
131
132
133
Transcribed Image Text:(to an setBalance(initialalance); MSa Run Detg 1Skop hre ba Minclude ciostream mn op te VinCiude cfstrean 3 includecstring 4 using namespace std; class Account{ int id; double balance publies 20 Account (){ id- balance =e.e; 11 12 10 14 15 Account (int newID, double initialBalance){ id newlD; balance-initialBalance; 16 17 18 19 20 21 veid setID(int newID){ id newID; void settalance(double initialBalance){ balance initialalance; 23 24 int getID() return id; 25 26 27 28 29 deuble getsalance(){ return balance; 30 31 32 veid withdraw(double amount){ balance balance amount; 33 34 35 void deposit(double amount){ balance balance mount: 36 37 38 virtual void closetonth()-e 39 virtual string accountstring()- 41 42 43 ); 44 elass Savings:public Account( double interest; double minbalance; public: Savings() 46 47 48 49 void eloselonth(){ double pre- getalance(); 51 52 53 double newialance - pre ((pre (interest/100.0))/12.0); 54 55 setBalance(newalance); 56 string accountstring() 57 59 return "Saving account + to_string(getID()) has balance of S"ito_string(getsalance()); 61 62 63 void setInterest(double interest){ this-interest-interest; void settintalance(double minBalance){ this-mintalance minsalance; 65 66 68 ); 69 - class Checking public Account( double minialance; double monthlyFee; 71 72 public: 73 Checking(){ 74 75 void closehonth() double nelalance getlalance() settalance(newalance); 76 77 78 monthlyfee; string accountstring() 81 return "Checking account+ to_string(getID()) +* has balance of s"-to_string(getBalance()); 82 83 84 void setMonthlyFee(double monthlyFee){ this- nonthlyfee nonthlyfee; 85 86 87 88 void setkinlalance(double minlalance){ this-minalance = minsalance; 89 91 92 ): 93 94- int nainO{ 95 Account accounts = new Account [10]; ifstrean infile; infile.open("bank2.txt"): if( infile ) cerr « "File cannont be opened" <« endl; else cout e "File Opened"<cendl; string operationType; int totalAccount-e; while(infileoperationType) 96 97 98 99 100 101 102 103 104 105 106 107 if(operationtype "Savings"H int id; double initialBalance,minimundalance, annualInterestRate; infile » id > initialBalance Savings "savingAccount- new Savings(); savingkccount-setInterest(annualInterestRate); savingaccount-setMinbalance(minimunalance); accounts(totalAccount] = savingaccount; accounts[totalAccount]-setID(id); accounts(totalAccount]-setBalance(initialBalance); tetalAccount; cout ce"Saving account nunber "cctotalAccount created"<endl; cout"with an initial balance of saccounts[totalAccount-1]-getBalance()cendi; 108 > ninimunsalance> annualInterestRate; 109 11e 111 112 113 114 115 116 117 118 119 12e 121 122 123 124 125 else if(operationType "Checking ) int id; double initialBalance,minimunbalance, nonthlyFees; infile » id > initialBalance >> ninimunsalance > 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 number "cctotalAccount « created"<cendl; cout"with an initial balance of S"accounts[totalAccount-1]-getBalance()cendl; 126 127 128 129 130 131 132 133
coutewith an initial balance of S"caccounts[totalAccount-1]-getBalance()<cendl;
133
134
135
else if (operationType "Deposit"){
int id;
double amount;
int pos;
bool isFound-=false;
infile >> 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 - "<cidccendl;
149
150
151
152
153
elsef
cout cc"Deposited $"<camountce" into account "<cidccendl;
cout<<"current balance is $"<caccounts[pos]-getBalance()<<endl;
154
155
156
else if (operationType == "kithdraw"){
int id;
double amount;
int pos;
infile >> 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()<cendl;
186
pos i;
187
188
189
ir(lisFound){
coutce"Invalid Account Number
190
191
*c«idccendl;
192
193
194
else if (operationType = "Close"){
cout"End of nonth processing complete"ccendl;
for(int i-e;itotalAccount;i+){
accounts[i]->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
Transcribed Image Text:coutewith an initial balance of S"caccounts[totalAccount-1]-getBalance()<cendl; 133 134 135 else if (operationType "Deposit"){ int id; double amount; int pos; bool isFound-=false; infile >> 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 - "<cidccendl; 149 150 151 152 153 elsef cout cc"Deposited $"<camountce" into account "<cidccendl; cout<<"current balance is $"<caccounts[pos]-getBalance()<<endl; 154 155 156 else if (operationType == "kithdraw"){ int id; double amount; int pos; infile >> 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()<cendl; 186 pos i; 187 188 189 ir(lisFound){ coutce"Invalid Account Number 190 191 *c«idccendl; 192 193 194 else if (operationType = "Close"){ cout"End of nonth processing complete"ccendl; for(int i-e;itotalAccount;i+){ accounts[i]->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
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY