-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path19.cpp
More file actions
46 lines (44 loc) · 1.5 KB
/
19.cpp
File metadata and controls
46 lines (44 loc) · 1.5 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
#include<iostream>
using namespace std;
int main() {
float balance = 1000.00;
int choice;
float amount;
while(true) {
cout << "Welcome to the ATM Machine" << endl;
cout << "1. Check Balance" << endl;
cout << "2. Deposit Money" << endl;
cout << "3. Withdraw Money" << endl;
cout << "4. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;
switch(choice) {
case 1:
cout << "Your balance is: $" << balance << endl;
break;
case 2:
cout << "Enter the amount you want to deposit: $";
cin >> amount;
balance += amount;
cout << "Deposit successful. Your new balance is: $" << balance << endl;
break;
case 3:
cout << "Enter the amount you want to withdraw: $";
cin >> amount;
if(amount > balance) {
cout << "Insufficient funds!" << endl;
} else {
balance -= amount;
cout << "Withdrawal successful. Your new balance is: $" << balance << endl;
}
break;
case 4:
cout << "Thank you for using the ATM. Goodbye!" << endl;
return 0;
default:
cout << "Invalid choice. Please try again." << endl;
}
cout << "\n-------------------------------------\n";
}
return 0;
}