-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.cpp
More file actions
72 lines (66 loc) · 1.34 KB
/
Copy pathAccount.cpp
File metadata and controls
72 lines (66 loc) · 1.34 KB
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
#include <iostream>
#include <iomanip>
using namespace std;
class Account
{
private:double balance;
public: double deposit(double bal);
double withdraw(double bal);
};
double Account::deposit(double bal)
{
balance=bal;
double dep;
cout<<"Enter the amount to be deposited"<<endl;
cin>>dep;
return (balance+dep);
}
double Account::withdraw(double bal)
{
balance=bal;
double temp,withdraw;
A:cout<<"Enter the amount to be withdrawed"<<endl;
cin>>withdraw;
temp=balance-withdraw;
if(temp<0)
{
cout<<"Withdrawal amount is more than remaining balance"<<endl;
goto A;
}
else
balance=temp;
return balance;
}
int main()
{
Account ob;
int ch;
double balance;
cout<<"Enter your account balance"<<endl;
cin>>balance;
B: cout<<"Enter the choice: \n 1 for Deposit \n 2 for Withdrawal \n 3 to check balance"<<endl;
cin>>ch;
switch(ch)
{
case 1:
{
cout<<"Account balance after Deposit = Rs"<<ob.deposit(balance);
break;
}
case 2:
{
cout<<"Account balance after Withdrwal = Rs"<<ob.withdraw(balance);
break;
}
case 3:
{
cout<<"Account balance = Rs"<<balance;
break;
}
default:
{
cout<<"Wrong Choice,Please re-enter the choice"<<endl;
goto B;
}
}
}