-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSwitch_Case_with_File.cpp
More file actions
62 lines (54 loc) · 1.89 KB
/
Switch_Case_with_File.cpp
File metadata and controls
62 lines (54 loc) · 1.89 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
#include<iostream>
#include<fstream>
using namespace std;
int main() {
int choice;
double balance=100000;
ofstream myfile;
myfile.open("test.txt", ios::out | ios::app);
cout<<".............Bank Management System.......... "<<endl;
cout<<"1. Create Account"<<endl;
cout<<"2. Deposit"<<endl;
cout<<"3. Withdraw"<<endl;
cout<<"4. Exit"<<endl;
cout<<"Enter your choice: ";
cin>>choice;
switch(choice) {
case 1:
cout<<"Account open successfully"<<endl;
myfile<<"Account Created. Initial Balance: "<<balance<<endl;
break;
case 2:
double deposit;
cout<<" Enter Amount to Deposit "<<endl;
cin>>deposit;
balance += deposit;
cout<<"Deposit Successfully; Now Your Current Balance is: "<<balance<<endl;
myfile<<"Deposit Successfully | Current Balance: "<<balance<<endl;
break;
case 3:
double withdraw;
cout<<"Enter Amount to Withdraw "<<endl;
cin>>withdraw;
if (withdraw <= balance) {
balance -= withdraw;
cout<<"Withdraw successful. Now Your remaining balance is "<<endl;
myfile << "Withdrawn: " << withdraw << " | Remaining Balance: " << balance << endl;
}
else {
balance += withdraw;
cout<<"Insufficient Balance"<<endl;
}
myfile<<"Failed Withdraw"<< withdraw<<"Balance is:"<<balance<<endl;
break;
case 4:
cout<<"Thank you for using my Banking System"<<endl;
myfile<<"Thank you for using my Banking System"<<endl;
break;
default:
cout<<"Invalid Entered by user"<<endl;
myfile<<"Invalid Entered by user, Please try again, Thank You"<<endl;
}
myfile.close();
return 0;
}