-
Notifications
You must be signed in to change notification settings - Fork 0
/
account_class.cpp
92 lines (91 loc) · 1.69 KB
/
account_class.cpp
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
//write a cpp programme to create an account class.The class should have the following functions
//1.function to create an account
//2.function to deposit an amount to an account
//3.function to withdraw amount from account
//4.function to display the balance available
#include<iostream>
using namespace std;
class account
{
private:
char name[20];
int type,amt,bal;
public:
void create();
void deposit();
void withdraw();
void display();
};
void account::create()
{
cout<<"enter name";
cin>>name;
cout<<"enter type of account 1)savings\t 2)current\t 3)RD\t 4)FD";
cin>>type;
int balance=0;
cout<<"balance is"<<bal;
}
void account::deposit()
{
cout<<"enter amt to be deposited";
cin>>amt;
bal+=amt;
cout<<"balance is"<<bal;
}
void account::withdraw()
{
cout<<"current balance is"<<bal;
cout<<"enter amount to be withdrawn";
cin>>amt;
if(bal>1000)
{
bal+=amt;
}
else
{
cout<<"balance insufficient";
}
cout<<"balance is"<<bal;
}
void account::display()
{
cout<<"the balance is";
cout<<bal<<endl;
cout<<"name is"<<name<<endl;
cout<<"account type is"<<type<<endl;
}
int main()
{
int i,n,c,p,count;
account a[10];
cout<<"enter no. of customers";
cin>>n;
count=1;
for(i=0;i<n;i++)
{
do
{
cout<<"customer no."<<count;
cout<<"options are 1.create\t 2.insert\t 3.withdraw";
cin>>c;
switch(c)
{
case 1:
a[i].create();
a[i].display();
break;
case 2:
a[i].deposit();
a[i].display();
break;
case 3:
a[i].withdraw();
a[i].display();
}
cout<<"do you want to continue";
cin>>p;
}while(p=1);
count+=1;
}
return 0;
}