bank account

i need to do a program that simulates a bank account without using classes and objects, but using functions etc
the program has to do all a bank account does deposit, withdraw etc
can someone help? :)

Heres What i came up with ;)

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
#include <iostream>

using namespace std;


int cashIn;
int cashInBank;

int main() {

	int cash = 100; //you can change this cuz why not

	while (true == true) {


		cout << "Welcome to the Espada City Bank! What would you like to do? Deposit(1) Withdraw(2) Never-Mind(3)""\n";
		int interaction;
		cin >> interaction;

		if (interaction == 1) {
			cout << "How much money would you like to deposit? You currently have " << cash << "$.""\n";
			cin >> cashIn;

			if (cashIn > cash) {
				cout << "You do not have that much money!""\n";
				continue;
			}
			else if (cashIn <= cash) {
				cash = cash - cashIn;
				cashInBank = cashInBank + cashIn;
				cashIn = 0;
				cout << "You currently have " << cashInBank << "$ In the bank." << "\n";
				continue;
			}
		}
		else if (interaction == 2) {
			cout << "How much money would you like to withdraw? You currently have " << cashInBank << "$ In the bank.""\n";
			int withdraw;
			cin >> withdraw;
			if (withdraw > cashInBank) {
				cout << "You do not have that much cash in the bank!""\n";
				continue;
			}
			else {
				cash = cash + withdraw;
				cashInBank = cashInBank - withdraw;
				cout << "Transaction Succsesful.""\n";
				continue;
			}
		}
		else {
			cout << "Come again soon!""\n";
			return 0;
		}
	}
}
Had lots of fun making it to! :)
If you would like to make a little login and registration system to it as well, just do something like:


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
#include <iostream>
#include <fstream>
using namespace std;

fstream Account("BankAccount.txt");

string username;

string password;

int main() {

	while (true == true) {

		cout << "Register(1) Login (2)""\n";
		int thing;
		cin >> thing;

		if (thing == 1) {
			cout << "What would you like your username to be?""\n";

			cin >> username;
			Account << username;

			cout << "What would you like your password to be?""\n";

			cin >> password;

			Account << password;
			continue;
		}
		if (thing == 2) {
			cout << "What is your username?""\n";
			string inName;
			cin >> inName;
			string inWord;
			cin >> inWord;

			if (inName == username && inWord == password) {
				cout << "Login succsessful.""\n";
				//bank things
			}
		}
	}
}
Last edited on
Topic archived. No new replies allowed.