Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 6a5d5ad

Browse files
committed
C++ programming
0 parents commit 6a5d5ad

File tree

288 files changed

+40733
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

288 files changed

+40733
-0
lines changed

‎Bank management system/BMS.cpp‎

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
#include "Header.h"
2+
3+
int main() {
4+
srand(time(0));
5+
::available = rand() % 200000;
6+
MainMenu();
7+
8+
system("color 9E");
9+
system("pause");
10+
return 0;
11+
}
12+
13+
void MainMenu() {
14+
system("color 9E");
15+
char num;
16+
char choice;
17+
do {
18+
19+
bool checked = false;
20+
string checkName, checkPassword;
21+
accounts data;
22+
accounts oldData[50];
23+
cout << "\n Choose what you want:";
24+
cout << "\n 1.Sign in";
25+
cout << "\n 2.Registration";
26+
cout << "\n 3.Exit";
27+
cout << "\n ";
28+
choice = _getch();
29+
switch (choice)
30+
{
31+
case 49:
32+
outData(oldData);
33+
system("CLS");
34+
cout << "\n Please enter your name:";
35+
cout << "\n ";
36+
cin >> checkName;
37+
cout << "\n Please enter your password:";
38+
cout << "\n ";
39+
cin >> checkPassword;
40+
for (int i = 0;i<::increaments; i++) {
41+
42+
if (oldData[i].name == checkName && oldData[i].password == checkPassword) {
43+
::accountNum = i;
44+
::balance = oldData[i].balance;
45+
::borrow = oldData[i].borrowed;
46+
checked = true;
47+
}
48+
49+
}
50+
if (checked) {
51+
do {
52+
system("CLS");
53+
cout << "\n Hello "<<oldData[::accountNum].name << endl;
54+
cout << "\n What would you like to do?" << endl;
55+
cout << "\n 1.Actions with card" << endl;
56+
cout << "\n 2.Check balance" << endl;
57+
cout << "\n 0.Exit" << endl;
58+
num = _getch();
59+
switch (num) {
60+
case 48:
61+
break;
62+
case 49: Menu(oldData);
63+
break;
64+
case 50: CheckBalance();
65+
break;
66+
default:
67+
cout << "\n Error! Section not found. Please try one more time." << endl << endl;
68+
system("pause");
69+
break;
70+
}
71+
72+
} while (num != '0');
73+
}
74+
else cout << "\n Wrong name or password\n";
75+
break;
76+
case 50:
77+
system("CLS");
78+
cout << "\n Input your name without space";
79+
cout << "\n ";
80+
cin >> data.name;
81+
cout << "\n Input yuor password without space";
82+
cout << "\n ";
83+
cin >> data.password;
84+
data.balance = 0;
85+
data.borrowed = 0;
86+
inputNewData(data);
87+
break;
88+
case 51:
89+
break;
90+
default:
91+
cout << "\n There is no such ssection";
92+
cout << "\n Please try one more time";
93+
break;
94+
}
95+
} while (choice != 51);
96+
97+
98+
99+
100+
101+
cout << "\n ";
102+
}
103+
104+
105+
106+

‎Bank management system/Header.h‎

Lines changed: 249 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,249 @@
1+
#pragma once
2+
#include<iostream>
3+
#include<fstream>
4+
#include<stdlib.h>
5+
#include<string>
6+
#include <vector>
7+
#include <windows.h>
8+
#include <ctime>
9+
#include <conio.h>
10+
11+
using namespace std;
12+
int accountNum, increaments;
13+
long double balance = 0;
14+
long double available;
15+
long double borrow = 0;
16+
struct accounts {
17+
18+
string name;
19+
string password;
20+
double balance;
21+
double borrowed;
22+
};
23+
//function declaring//////////////////////////////////////////
24+
void CheckBalance();
25+
void Borrow();
26+
void Deposit();
27+
void Return();
28+
void Menu(accounts oldData[]);
29+
void MainMenu();
30+
void outData(accounts oldData[]);
31+
void inputNewData(accounts data);
32+
void inputUpgradeData(accounts data[]);
33+
///////////////////////////////////////////////////////////////
34+
//function defintion///////////////////////////////////////////
35+
void Menu(accounts oldData[]) {
36+
char num = '1';
37+
while (num != '0')
38+
{
39+
system("CLS");
40+
cout << "\n 1.Deposit" << endl;
41+
cout << "\n 2.Borrow money from bank" << endl;
42+
cout << "\n 3.Return money to bank" << endl << endl;
43+
cout << "\n If you want to quit from this section please press 0" << endl << endl;
44+
num = _getch();
45+
switch (num) {
46+
case 49:
47+
system("CLS");
48+
Deposit();
49+
oldData[accountNum].balance = ::balance;
50+
inputUpgradeData(oldData);
51+
break;
52+
case 50:
53+
system("CLS");
54+
Borrow();
55+
oldData[accountNum].balance = ::balance;
56+
oldData[accountNum].borrowed = ::borrow;
57+
inputUpgradeData(oldData);
58+
break;
59+
case 51:
60+
system("CLS");
61+
Return();
62+
oldData[accountNum].balance = ::balance;
63+
oldData[accountNum].borrowed = ::borrow;
64+
inputUpgradeData(oldData);
65+
break;
66+
}
67+
}
68+
cout << "\n ";
69+
}
70+
71+
void CheckBalance() {
72+
system("CLS");
73+
cout << "\n You balance: " << ::balance << "$" << endl << endl;
74+
cout << "\n ";
75+
system("pause");
76+
}
77+
78+
void Deposit()
79+
{
80+
double money;
81+
cout << "\n Please enter amount of money - ";
82+
cin >> money;
83+
if (money == 0)
84+
{
85+
cout << "\n You entered 0 value so now you are redirected to the menu" << endl;
86+
Sleep(2000);
87+
}
88+
else if (money > 0)
89+
{
90+
::balance = ::balance + money;
91+
92+
cout << "\n Please wait for a while, while we are transfering money to your account" << endl;
93+
Sleep(2000);
94+
cout << "\n ";
95+
cout << money << "$ amount of money was added to your balance" << endl << endl;
96+
}
97+
else
98+
{
99+
cout << "\n Error!" << endl;
100+
cout << "\n Please enter valid amount of money!" << endl << endl;
101+
}
102+
cout << "\n ";
103+
system("pause");
104+
}
105+
106+
void Borrow()
107+
{
108+
long double borrow;
109+
cout << "\n In during time in our bank we have " << ::available << "$" << endl;
110+
cout << "\n How much do you want to borrow?" << endl;
111+
cout << "\n ";
112+
cin >> borrow;
113+
if (borrow == 0)
114+
{
115+
cout << "\n You entered 0 value so now you are redirected to the menu" << endl << endl;
116+
Sleep(2000);
117+
}
118+
else if (borrow <= ::available && borrow > 0)
119+
{
120+
cout << "\n We can give you such amount of money." << endl;
121+
cout << "\n Please wait for a while, while we are transfering money to your account" << endl;
122+
Sleep(3000);
123+
::available = ::available - borrow;
124+
::balance = ::balance + borrow;
125+
::borrow = ::borrow + borrow;
126+
cout << "\n Money is successfully transfered to your account." << endl << endl;
127+
}
128+
else if (::borrow < 0)
129+
{
130+
cout << "\n Error!" << endl;
131+
cout << "\n Please enter valid amount of money!" << endl << endl;
132+
}
133+
else {
134+
cout << "\n We are sorry but we cant give you such amount of money" << endl << endl;
135+
}
136+
cout << "\n ";
137+
system("pause");
138+
}
139+
140+
void Return()
141+
{
142+
char choise;
143+
long double retr;
144+
if (::borrow > 0) {
145+
cout << "\n You have borrowed - " << ::borrow << "$" << endl;
146+
cout << "\n If you want to return some amount of money please press SPACE or press anything to go back to menu." << endl;
147+
choise = _getch();
148+
if (choise == 32) {
149+
cout << "\n How much do you want to return?" << endl;
150+
cout << "\n ";
151+
cin >> retr;
152+
if (retr == 0)
153+
{
154+
cout << "\n You entered 0 value so now you are redirected to the menu" << endl;
155+
Sleep(2000);
156+
}
157+
else if (retr > 0 && retr <= ::borrow) {
158+
cout << "\n Please wait while we are taking from your account money back." << endl;
159+
::borrow = ::borrow - retr;
160+
::balance = ::balance - retr;
161+
::available = ::available + retr;
162+
Sleep(3000);
163+
cout << "\n Money is successfully taken from your account." << endl << endl;
164+
}
165+
else
166+
{
167+
cout << "\n Error!" << endl;
168+
cout << "\n Please enter valid amount of money!" << endl << endl;
169+
}
170+
}
171+
}
172+
else {
173+
cout << "\n You haven't borrowed any money from us." << endl << endl;
174+
}
175+
cout << "\n ";
176+
system("pause");
177+
}
178+
179+
void outData(accounts oldData[]) {
180+
ifstream file;
181+
file.open("data.txt");
182+
if (!file.is_open()) {
183+
cout << "Error\n";
184+
185+
}
186+
else {
187+
//cout << "file is opened\n";
188+
string str = "";
189+
int i = 0, j = 0;
190+
string strArr[4];
191+
do {
192+
getline(file, str, '|');
193+
if (j < 4) {
194+
strArr[j] = str;
195+
j++;
196+
}
197+
else {
198+
oldData[i].name = strArr[0];
199+
oldData[i].password = strArr[1];
200+
oldData[i].balance = stoi(strArr[2]);
201+
oldData[i].borrowed = stoi(strArr[3]);
202+
::increaments++;
203+
j = 0;
204+
strArr[j] = str;
205+
j++;
206+
i++;
207+
}
208+
209+
210+
211+
//cout<<str<<"|";
212+
}while (!file.eof());
213+
}
214+
}
215+
void inputNewData(accounts data) {
216+
ofstream file;
217+
file.open("data.txt", ofstream::app);
218+
file << data.name;
219+
file << "|";
220+
file << data.password;
221+
file << "|";
222+
file << data.balance;
223+
file << "|";
224+
file << data.borrowed;
225+
file << "|";
226+
227+
228+
229+
230+
file.close();
231+
}
232+
void inputUpgradeData(accounts data[]) {
233+
ofstream file;
234+
file.open("data.txt");
235+
for (int i = 0; i <::increaments; i++) {
236+
237+
file << data[i].name;
238+
file << "|";
239+
file << data[i].password;
240+
file << "|";
241+
file << data[i].balance;
242+
file << "|";
243+
file << data[i].borrowed;
244+
file << "|";
245+
246+
}
247+
248+
file.close();
249+
}

‎Bank management system/Project3.exe‎

161 KB
Binary file not shown.

‎Bank management system/data.txt‎

Whitespace-only changes.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /