-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLAB4.cpp
More file actions
96 lines (94 loc) · 2.22 KB
/
Copy pathLAB4.cpp
File metadata and controls
96 lines (94 loc) · 2.22 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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
/*Develop a C++ program using classes for a bank empolyee to print name of the employee, account_no. & balance.
Print invalid balance if amount<500, Display the same, also display the balance after withdraw and
deposit.*/
#include<iostream>
using namespace std;
class BankEmployee
{
private:
string name;
int account_no;
float balance;
public:
void input()
{
cout<<"Enter Name : ";
cin>>name;
cout<<"Enter Account No. : ";
cin>>account_no;
cout<<"Enter Balance : ";
cin>>balance;
}
void display()
{
cout<<"Name: "<<name<<endl;
cout<<"Account No: "<<account_no<<endl;
if(balance>500)
cout<<"Balance: "<<balance<<endl;
else
cout<<"Invalid balance(less than 500)"<<endl;
}
void withdraw(float amount)
{
cout<<"Available Balance : "<<balance<<endl;
if(balance<=500)
{
cout<<"Invalid balance(less than 500)"<<endl;
}
else
{
if(amount<=balance)
{
balance=balance-amount;
cout<<"Balance after withdrawal: "<<balance<<endl;
}
else
{
cout<<"Insufficient balance"<<endl;
}
}
}
void deposit(float amount)
{
balance=balance+amount;
cout<<"Balance after deposit: "<<balance<<endl;
}
};
int main()
{
BankEmployee emp;
emp.input();
int ch;
while(1)
{
cout<<"\n1.Display\n2.Withdraw\n3.Deposit\n4.exit"<<endl;
cout<<"choose an option : ";
cin>>ch;
if(ch==1)
emp.display();
else if(ch==2)
{
float amount;
cout<<"Enter amount to withdraw : ";
cin>>amount;
emp.withdraw(amount);
}
else if (ch==3)
{
float amount;
cout<<"Enter amount to deposit : ";
cin>>amount;
emp.deposit(amount);
}
else if (ch==4)
{
cout<<"Exiting the program"<<endl;
break;
}
else
{
cout<<"Invalid choice"<<endl;
continue;
}
}
}