-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.cpp
More file actions
84 lines (77 loc) · 2.39 KB
/
Copy pathmain.cpp
File metadata and controls
84 lines (77 loc) · 2.39 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
// Banking System
#include <iostream>
#include <fstream>
#include <cstdlib>
using namespace std;
int main()
{
string Username;
string Paswword;
int x = 0; // the option the user will choose
int y = 0; // withdrawl money
int r = 0;
double balance;
bool running = true;
ifstream inputfile("balance.txt");
inputfile >> balance;
inputfile.close();
cout << " Good afternoon Sir/mam \n Username : ";
cin >> Username;
system("cls");
cout << "password : ";
cin >> Paswword;
if (Username == "Username" && Paswword == "admin")//change it if you need to
{
while (running)
{
system("cls");
cout << "Welcome to your Account " << Username << endl;
cout << "Please choose one of the following options : \n";
cout << "1.Check account balance. \n2.Withdraw Money. \n3.Insert Money.\n4.Exit\n> ";
cin >> x;
switch (x)
{
case 1:
system("cls");
cout << "Your balance is " << balance << endl;
break;
case 2:
cout << "You currently have " << balance << "\nHow much Do you want to withdraw?\n>";
cin >> y;
if (y > balance)
{
cout << "You are too broke\n";
}
else
{
balance = balance - y;
cout << "Done! You currently have " << balance << endl;
}
break;
case 3:
cout << "How much money are you willing to insert? : ";
cin >> r;
balance = balance + r;
cout << "Done! You currently have " << balance << endl;
break;
case 4:
cout<<"exiting..\n";
running = false ;
break;
default :
cout << "Invalid option!\n";
;
break;
; }system("pause");
}
}
else
{
cout << "wrong credentials !" << endl;
system("pause");
}
fstream outfile("Balance.txt");
outfile << balance;
outfile.close();
return 0;
}