-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathbankaccountinfo.cpp
More file actions
85 lines (79 loc) · 2.69 KB
/
bankaccountinfo.cpp
File metadata and controls
85 lines (79 loc) · 2.69 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
#include <iostream>
#include <string>
using namespace std;
class Bank_Account
{
private:
string account_name;
string account_number;
int curr_balance;
public:
Bank_Account() : curr_balance(0)
{
cout << "Enter Account Holder Name: ";
getline(cin, account_name);
cout << "Enter Account Number: ";
cin >> account_number;
cout << "Account created successfully!\n";
}
void getInfo()
{
int choice;
do {
cout << "\n---------- Menu ----------";
cout << "\n1. Credit";
cout << "\n2. Debit";
cout << "\n3. Display Mini Statement";
cout << "\n4. Exit";
cout << "\nEnter your choice: ";
cin >> choice;
switch (choice)
{
case 1:
{
int credit_amount;
cout << "Enter the amount to credit: ";
cin >> credit_amount;
curr_balance += credit_amount;
cout << "Credited successfully!\n";
break;
}
case 2:
{
int debit_amount;
cout << "Enter the amount to debit: ";
cin >> debit_amount;
if(curr_balance >= debit_amount)
{
curr_balance -= debit_amount;
cout << "Debited successfully!\n";
}
else
{
cout << "Insufficient balance!\n";
}
break;
}
case 3:
{
cout << "\n---------- Mini Statement ----------";
cout << "\nAccount Holder: " << account_name;
cout << "\nAccount Number: " << account_number;
cout << "\nCurrent Balance: " << curr_balance << endl;
break;
}
case 4:
cout << "Exiting... Thank you!\n";
break;
default:
cout << "Invalid choice! Please try again.\n";
}
} while (choice != 4);
}
};
int main()
{
Bank_Account acc1;
acc1.getInfo();
return 0;
}