-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank3.cpp
112 lines (111 loc) · 2.06 KB
/
bank3.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
#include <iostream>
#include <stdio.h>
using namespace std;
class bankAcc
{
public:
int accno;
string name;
float am;
/*bankAcc(int A,string n,float R){
accno=A;
name=n;
am=R; }*/
void deposit()
{
float da;
cout << "Enter deposit amount:" << endl;
cin >> da;
am = am + da;
cout << "Amount in your account after deposit:" << am << endl;
}
void withdraw()
{
float wa;
cout << "Enter withdraw amount:" << endl;
cin >> wa;
if ((am - wa) > 2500)
{
am -= wa;
cout << "Amount in your account after withdrawl:" << am << endl;
}
else
{
cout << "Minimum balance exceeded!!" << endl;
cout << "First deposit amount!" << endl;
}
}
};
class current: public bankAcc
{
public:
current(int A, string n, float R)
{
accno = A;
name = n;
am = R;
}
void greet()
{
int ch;
cout << "Welcome to your current account" << endl;
cout << "What do you want to do?\nEnter 1 for deposit and 2 for withdrawl" << endl;
cin >> ch;
if ((ch) == 1)
{
deposit();
}
else
{
withdraw();
}
}
};
class saving : public bankAcc
{
public:
saving(int A, string n, float R)
{
accno = A;
name = n;
am = R;
}
void greet()
{
int c;
cout << "Welcome to your saving account" << endl;
cout << "What do you want to do?\nEnter 1 for deposit and 2 for withdrawl" << endl;
cin >> c;
if (c == 1)
{
deposit();
}
else
{
withdraw();
}
}
};
int main()
{
int accno, c;
string name;
float am;
cout << "Welcome to your bank account" << endl;
cout << "Enter accno,name and amount" << endl;
cin >> accno >> name >> am;
//bankAcc b1(accno,name,am);
cout << "What is your account?\nEnter 1 for current and 2 for saving" << endl;
cin >> c;
if ((c) == 1)
{
current c1(accno, name, am);
c1.greet();
}
else
{
saving s1(accno, name, am);
s1.greet();
}
return 0;
}