Any one can do?

ANYONE CAN HELP TO DO THIS?

2. Problem statement

Assume that ABC bank has three types of deposits and saving account for customers as
shown in the table below.
Saving
account
Golden account Fixed Deposit
<$50,000 >$50,000 1 year 2 year 3 year
Minimum balance $100 $100 $50,000 $5000
Interest 0.25% 0.25% 0.375% 0.55% 0.7% 0.8%
Additional interest - 0.125% 0.125% - - -
Maturity Date - - - Enter by user
Age - >55 - - -
Penalty for
withdrawal before
maturity date
$50 $100 $150

Saving account can be open with a minimum deposit of $100. It provides interest at
0.25%. User can deposit and withdraw money from this account at any time. Depositors
aged 55 years old are eligible to open a Golden account. This account will offer an
additional interest of 0.125% on top of the normal interest of 0.25% for deposit amount
less than $50,000. For amount above $50,000, the prevailing interest is higher at 0.375%.
Fixed deposit can be open with a minimum amount of $5000. The interest rate for
placement of 1 year, 2 year and 3 year is at 0.55%, 0.7% and 0.8% respectively. However,
if the deposit amount is withdrew before the maturity date, a penalty amount range from
$50 to $150 will be imposed and the interest will be computed based on the normal
saving account interest rate.

Design the necessary classes and member functions to achieve the following tasks :
a. Allow user to enter bank account information. Each bank account should have
customer name, account number, age and type of deposit.
b. Accept deposit/withdrawal from a customer and update the balance.
c. Give a warning and stop the withdrawal if balance is less than 0 for all accounts.
d. Display balance.
e. Check the age of the depositor for opening of Golden account.
f. Add an additional interest of 0.125% when computing interest for Golden account.
g. Impose penalty and compute interest based on the saving account’s interest rate if
the fixed deposit is withdrew before the maturity date.
h. Detail transaction of each account should be updated in a text file.
We can help, but you should show us your efforts: http://www.cplusplus.com/forum/articles/1295/
This is my work is not fully done yet still have lot of problem i can't sovle. And questions about Maturity Date,Penalty for
withdrawal before maturity date,Golden account Fixed Deposit don't know how to write. I can display well the customer data well for two or more.


#include <iostream>
#include <string>
#include <fstream>

using namespace std;

class AccInfo
{
protected:
string name, type, accno;
int age;
double balance;

public:
AccInfo(){}
void BasicMenu(void);
void CreateAcc(void);
void savedata(void);
void savedata2(void);
void readdata(void);
void Deposit(void);
void Withdraw(void);
void display(void);
void checkbal(double balance);
};


void AccInfo::BasicMenu(void)
{
cout << "<1> Create Account."<<endl;
cout << "<2> Display Account."/*(Key in Account No.)*/<<endl;
cout << "<3> Deposit."<<endl;
cout << "<4> Withdraw."<<endl;
cout << "<5> Calculate Interest."<<endl;
cout << "<6> Quit Bank Program."<<endl;
}

void AccInfo::CreateAcc(void)
{
string na, ty, no;
int ag;
float amt;

cout<<"Please enter the account user name : ";
fflush(stdin);
getline(cin, na);
cout<<"Please enter Age : ";
cin>>ag;
fflush(stdin);
cout<<"Please enter the account number : ";
getline(cin, no);
cout<<"Please enter the account type : ";
getline(cin, ty);
cout<<"Amount to be deposited into the account : ";
cin>>amt;
name = na;
age = ag;
type = ty;
accno = no;
balance = amt;
}

void AccInfo::savedata(void)
{

ofstream outfile;

outfile.open("c:\\CreatedAcc.txt",fstream::app);
//outfile.seekp (0, ios_base::end);
outfile<<"Name : "<<name<<endl;
outfile<<"Age : "<<age<<endl;
outfile<<"Account Number : "<<accno<<endl;
outfile<<"Account Type : "<<type<<endl;
outfile<<"Balance : "<<balance<<endl<<endl;
outfile.close();
}

void AccInfo::savedata2(void)
{

ofstream outfile;

outfile.open("c:\\DataBase.txt",fstream::app);
//outfile.seekp (0, ios_base::end);
outfile<<name <<endl; //"\t" ;//<<endl;
outfile<<age <<endl;//"\t" ;//endl;
outfile<<accno <<endl;//"\t" ;//<<endl;
outfile<<type <<endl;//"\t" ;//endl;
outfile<<balance <<endl<<endl;//"\t" ;//endl;
outfile.close();
}



void AccInfo::readdata(void)
{
ifstream infile;
string show;

if (infile == 0)
cout<<"File not found!!!"<<endl;
else
{
cout << "Please key in your Account Name : ";
fflush(stdin);
getline(cin, name);
//infile.open("c:\\Database.txt");
infile.open("c:\\DataBase.txt",fstream::beg);
//infile.seekp (0, ios_base::end);
fflush(stdin);
//infile>>show;
//getline(infile,show);
//cout<<show<<endl;

while (show != name)
{
getline(infile, show);
fflush(stdin);
}

cout<<"Name : "<<name<<endl;
getline(infile,accno);
cout<<"Age : "<<age<<endl;
getline(infile,accno);
cout<<"Account Number : "<<accno<<endl;
getline(infile,type);
cout<<"Account Type : "<<type<<endl;
getline(infile,show);
//cout<<"Balance : "<<show<<endl;
//getline(infile,amt);
//while(!infile.eof())
//{
//getline(infile,show);
//cout<<"Balance : "<<show<<endl;
//}
cout<<"Balance : "<<balance<<endl<<endl;
infile.close();
}
}

void AccInfo::Deposit(void)
{
int choice;
double amt;
cout <<"<1> Deposit $100."<<endl;
cout <<"<2> Deposit $200."<<endl;
cout <<"<3> Deposit $300."<<endl;
cout <<"<4> Deposit $400."<<endl;
cout <<"<5> Deposit $500."<<endl;
cout <<"<6> Other Deposit."<<endl;
cout <<"<7> Quit Deposit."<<endl;
do{
cin >> choice;
switch (choice)
{
case 1 : balance = balance + 100;
break;
case 2 : balance = balance + 200;
break;
case 3 : balance = balance + 300;
break;
case 4 : balance = balance + 400;
break;
case 5 : balance = balance + 500;
break;
case 6 : cout << "Please key in the amount to be deposit : $";
cin >> amt;
balance = balance + amt;
break;
case 7 : break;
default: cout << "Wrong Choice!"<<endl;
cout << "Please key in a valid option : ";
}
} while(choice == 0 || choice > 7);
}

void AccInfo::Withdraw(void)
{
int choice;
double amt;
cout <<"<1> Withdraw $100."<<endl;
cout <<"<2> Withdraw $200."<<endl;
cout <<"<3> Withdraw $300."<<endl;
cout <<"<4> Withdraw $400."<<endl;
cout <<"<5> Withdraw $500."<<endl;
cout <<"<6> Other Withdrawal."<<endl;
cout <<"<7> Quit Withdrawal."<<endl;
do{
cin >> choice;
if (balance)
switch (choice)
{
case 1 : if(balance - 100 <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - 100;
break;
}
case 2 : if(balance - 200 <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - 200;
break;
}
case 3 : if(balance - 300 <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - 300;
break;
}
case 4 : if(balance - 400 <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - 400;
break;
}
case 5 : if(balance - 500 <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - 500;
break;
}
case 6 : cout << "Please key in the amount to be deposit : $";
cin >> amt;
if(balance - amt <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - amt;
break;
}
case 7 : break;
default: cout << "Wrong Choice!"<<endl;
cout << "Please key in a valid option : ";
}
} while(choice == 0 || choice > 7);
};
-----------------------------------------------------------------------------------------------------
Main
------------------------------------------------------------------------------------------------------
#include "Account_Info.h"
#include <iostream>
#include <string>

using namespace std;

int main()
{
int menuchoice;
string na;
AccInfo Acc;
do
{
Acc.BasicMenu();
cout<<"Please enter your choice : ";
cin >> menuchoice;
switch(menuchoice)
{
case 1 : cout <<"Creating Account."<<endl;
Acc.CreateAcc();
Acc.savedata();
Acc.savedata2();
cout <<"Account Created!"<<endl;
break;
case 2 : Acc.readdata();
break;
case 3 : Acc.Deposit();
Acc.savedata();
Acc.savedata2();
//Acc.readdata();
break;
case 4 : Acc.Withdraw();
Acc.savedata();
Acc.savedata2();
break;
case 6 : cout << "Quitting Program!"<<endl;
break;
default: cout<<"Wrong choice entered!"<<endl;
cout<<"Please enter again! "<<endl;
}
}while (menuchoice != 6);
}
post code using the code tags, it makes it easier to read
(paste the code, highlight it, then click the # button at the side)
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#include <iostream>
#include <string>
#include <fstream>

using namespace std;

class AccInfo
{
protected:
string name, type, accno;
int age;
double balance;

public:
AccInfo(){}
void BasicMenu(void);
void CreateAcc(void);
void savedata(void);
void savedata2(void);
void readdata(void);
void Deposit(void);
void Withdraw(void);
void display(void);
void checkbal(double balance);
};


void AccInfo::BasicMenu(void)
{
cout << "<1> Create Account."<<endl;
cout << "<2> Display Account."/*(Key in Account No.)*/<<endl;
cout << "<3> Deposit."<<endl;
cout << "<4> Withdraw."<<endl;
cout << "<5> Calculate Interest."<<endl;
cout << "<6> Quit Bank Program."<<endl;
}

void AccInfo::CreateAcc(void)
{
string na, ty, no;
int ag;
float amt;

cout<<"Please enter the account user name : ";
fflush(stdin);
getline(cin, na);
cout<<"Please enter Age : ";
cin>>ag;
fflush(stdin);
cout<<"Please enter the account number : ";
getline(cin, no);
cout<<"Please enter the account type : ";
getline(cin, ty);
cout<<"Amount to be deposited into the account : ";
cin>>amt;
name = na;
age = ag;
type = ty;
accno = no;
balance = amt;
}

void AccInfo::savedata(void)
{

ofstream outfile;

outfile.open("c:\\CreatedAcc.txt",fstream::app);
//outfile.seekp (0, ios_base::end);
outfile<<"Name : "<<name<<endl;
outfile<<"Age : "<<age<<endl;
outfile<<"Account Number : "<<accno<<endl;
outfile<<"Account Type : "<<type<<endl;
outfile<<"Balance : "<<balance<<endl<<endl;
outfile.close();
}

void AccInfo::savedata2(void)
{

ofstream outfile;

outfile.open("c:\\DataBase.txt",fstream::app);
//outfile.seekp (0, ios_base::end);
outfile<<name <<endl; //"\t" ;//<<endl;
outfile<<age <<endl;//"\t" ;//endl;
outfile<<accno <<endl;//"\t" ;//<<endl;
outfile<<type <<endl;//"\t" ;//endl;
outfile<<balance <<endl<<endl;//"\t" ;//endl;
outfile.close();
}



void AccInfo::readdata(void)
{
ifstream infile;
string show;

if (infile == 0)
cout<<"File not found!!!"<<endl;
else
{
cout << "Please key in your Account Name : ";
fflush(stdin);
getline(cin, name);
//infile.open("c:\\Database.txt");
infile.open("c:\\DataBase.txt",fstream::beg);
//infile.seekp (0, ios_base::end);
fflush(stdin);
//infile>>show;
//getline(infile,show);
//cout<<show<<endl;

while (show != name)
{
getline(infile, show);
fflush(stdin);
}

cout<<"Name : "<<name<<endl;
getline(infile,accno);
cout<<"Age : "<<age<<endl;
getline(infile,accno);
cout<<"Account Number : "<<accno<<endl;
getline(infile,type);
cout<<"Account Type : "<<type<<endl;
getline(infile,show);
//cout<<"Balance : "<<show<<endl;
//getline(infile,amt);
//while(!infile.eof())
//{
//getline(infile,show);
//cout<<"Balance : "<<show<<endl;
//}
cout<<"Balance : "<<balance<<endl<<endl;
infile.close();
}
}

void AccInfo::Deposit(void)
{
int choice;
double amt;
cout <<"<1> Deposit $100."<<endl;
cout <<"<2> Deposit $200."<<endl;
cout <<"<3> Deposit $300."<<endl;
cout <<"<4> Deposit $400."<<endl;
cout <<"<5> Deposit $500."<<endl;
cout <<"<6> Other Deposit."<<endl;
cout <<"<7> Quit Deposit."<<endl;
do{
cin >> choice;
switch (choice)
{
case 1 : balance = balance + 100;
break;
case 2 : balance = balance + 200;
break;
case 3 : balance = balance + 300;
break;
case 4 : balance = balance + 400;
break;
case 5 : balance = balance + 500;
break;
case 6 : cout << "Please key in the amount to be deposit : $";
cin >> amt;
balance = balance + amt;
break;
case 7 : break;
default: cout << "Wrong Choice!"<<endl;
cout << "Please key in a valid option : ";
}
} while(choice == 0 || choice > 7);
}

void AccInfo::Withdraw(void)
{
int choice;
double amt;
cout <<"<1> Withdraw $100."<<endl;
cout <<"<2> Withdraw $200."<<endl;
cout <<"<3> Withdraw $300."<<endl;
cout <<"<4> Withdraw $400."<<endl;
cout <<"<5> Withdraw $500."<<endl;
cout <<"<6> Other Withdrawal."<<endl;
cout <<"<7> Quit Withdrawal."<<endl;
do{
cin >> choice;
if (balance)
switch (choice)
{
case 1 : if(balance - 100 <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - 100;
break;
}
case 2 : if(balance - 200 <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - 200;
break;
}
case 3 : if(balance - 300 <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - 300;
break;
}
case 4 : if(balance - 400 <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - 400;
break;
}
case 5 : if(balance - 500 <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - 500;
break;
}
case 6 : cout << "Please key in the amount to be deposit : $";
cin >> amt;
if(balance - amt <= 0)
{
cout << "Withdrawal not granted. Balance not changed."<<endl;
break;
}
else
{
balance = balance - amt;
break;
}
case 7 : break;
default: cout << "Wrong Choice!"<<endl;
cout << "Please key in a valid option : ";
}
} while(choice == 0 || choice > 7);
};
Main
------------------------------------------------------------------------------------------------------
#include "Account_Info.h"
#include <iostream>
#include <string>

using namespace std;

int main()
{
int menuchoice;
string na;
AccInfo Acc;
do
{
Acc.BasicMenu();
cout<<"Please enter your choice : ";
cin >> menuchoice;
switch(menuchoice)
{
case 1 : cout <<"Creating Account."<<endl;
Acc.CreateAcc();
Acc.savedata();
Acc.savedata2();
cout <<"Account Created!"<<endl;
break;
case 2 : Acc.readdata();
break;
case 3 : Acc.Deposit();
Acc.savedata();
Acc.savedata2();
//Acc.readdata();
break;
case 4 : Acc.Withdraw();
Acc.savedata();
Acc.savedata2();
break;
case 6 : cout << "Quitting Program!"<<endl;
break;
default: cout<<"Wrong choice entered!"<<endl;
cout<<"Please enter again! "<<endl;
}
}while (menuchoice != 6);
}


that's better
Thanks hypercube1 but can u or anyone help me with the program?
thanks
Last edited on
Topic archived. No new replies allowed.