Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <iomanip>
- #include <random>
- using namespace std;
- int main();
- void gowhere();
- void deposit();
- void witdraw();
- void check();
- double moneytotal = 0, addmoney, withdrawMoney;
- int menu1, upass, hmu = 1, userspot = 0;
- int a = 0, b = 0; //counters
- string username, password, newuser, newpass;
- string usernames[100] = {"Jason"};
- string passwords[100] = {"password"};
- int main() {
- cout << "=======Welcome======\n"
- << "1. Login\n"
- << "2. Create user\n"
- << "3. Quit\n\n";
- cin >> menu1;
- switch (menu1) {
- case 1: cout << "=======================\n"
- << "Please enter Username: ";
- while (a == 0) {
- cin >> username;
- for (int x = 0 ; x < hmu ; x++) {
- if (username == usernames[x]) {
- upass = x;
- a += 1;
- break;
- }
- else if (username != usernames[x]) {
- continue;
- }
- }
- }
- case 4: cout << "\nPlease enter password: ";
- while (b == 0) {
- cin >> password;
- if (password == passwords[upass]) {
- cout << "\n" << "Welcome " << username << endl;
- b += 1;
- }
- else {
- cout << "Not correct please try again: ";
- }
- }
- break;
- case 2: cout << "\nType your new username: ";
- cin >> newuser;
- hmu += 1;
- userspot += 1;
- usernames[userspot] = newuser;
- cout << "\nEnter your password: ";
- cin >> newpass;
- passwords[userspot] = newpass;
- cout << "\nAll done\n";
- break;
- case 3: cout << "Thank you for using ATM. Have a nice day";
- exit(0);
- case 5: for (int x = 0 ; x < 100 ; x++) {
- cout << usernames[x] << endl;
- }
- }
- gowhere();
- }
- void gowhere() {
- int menu2, moneytotal = 0;
- cout << "\n====================\n\n"
- << "What whould you like to do?\n"
- << "1. Deposit\n"
- << "2. Withdraw\n"
- << "3. Check Balance\n"
- << "4. Quit\n\n";
- cin >> menu2;
- switch (menu2) {
- case 1: deposit();
- break;
- case 2: witdraw();
- break;
- case 3: check();
- break;
- case 4: main();
- default: cout << "Not a choice try again";
- gowhere();
- }
- }
- void deposit() {
- cout << "\nDeposit how much: ";
- cin >> addmoney;
- moneytotal += addmoney;
- cout << "\nDone\n";
- gowhere();
- }
- void witdraw() {
- cout << "\nWithdraw how much: ";
- cin >> withdrawMoney;
- moneytotal -= withdrawMoney;
- if (moneytotal < 0) {
- moneytotal += withdrawMoney;
- cout << "\nYou cannot withdraw that much\n";
- gowhere();
- }
- else {
- cout << "\nDone\n";
- gowhere();
- }
- }
- void check() {
- string goback;
- cout << "\n====================\n"
- << "Your total: " << moneytotal << "\n"
- << "====================\n"
- << "Type \'OK\' to go back: ";
- cin >> goback;
- if (goback == "OK") {
- gowhere();
- }
- else {
- gowhere();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement