Created
July 21, 2019 23:58
-
-
Save coderedart/1529e4a6a3b71954d29e3958eef7bdc0 to your computer and use it in GitHub Desktop.
asking for help from exp people in discord
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
#include <fstream> | |
using std::cout; | |
using std::cin; | |
using std::ifstream; | |
using std::ofstream; | |
using std::fstream; | |
using std::string; | |
using std::endl; | |
class bank_account { | |
public: | |
string name = ""; | |
long mobile = 0000000000; | |
long account = 0000000000; | |
double balance = 0; | |
int withdraw(double &money){ | |
if (this->balance < money) { | |
return 1; | |
} | |
this->balance = this->balance - money; | |
return 0; | |
} | |
void deposit(double &money){ | |
this->balance += money; | |
} | |
double check_balance(){ | |
return this->balance; | |
} | |
private: | |
char password[20]; | |
}; | |
int setname(bank_account & temp, string tname) { | |
temp.name = tname; | |
return 0; | |
} | |
string getname(bank_account & temp) { | |
return temp.name; | |
} | |
string ask = "\nWhat would you like to do?\n" | |
"1. check my balance\n" | |
"2. deposit money\n" | |
"3. withdraw money\n" | |
"4. what is my name in the bank account details\n" | |
"5. update my name in bank database\n" | |
"6. exit\n" | |
; | |
int main() { | |
int choice = 0; | |
bank_account red; | |
string trash_string = ""; | |
double trash_double = 0; | |
int trash_int = 0; | |
while (true) { | |
cout << ask << endl; | |
cin >> choice; | |
if (choice > 6 || choice < 1) { | |
cout << "wrong option, please select from the give choices" << endl; | |
cin.ignore(); | |
continue; | |
} | |
switch (choice) { | |
case 1: | |
cout << "your balance is " << red.balance << endl; | |
break; | |
case 2: | |
cout << "enter the amount you would like to deposit" << endl; | |
cin >> trash_double; | |
red.deposit(trash_double); | |
break; | |
case 3: | |
cout << "enter the amount you would like to withdraw" << endl; | |
cin >> trash_double; | |
red.withdraw(trash_double); | |
break; | |
case 4: | |
cout << "your name in bank database is " << getname(red) << endl; | |
break; | |
case 5: | |
cout << "enter the name to update your details in bank database" << endl; | |
cin.ignore(); | |
std::getline(std::cin, trash_string); | |
setname(red, trash_string); | |
cout << "name changed successfullly" << endl; | |
break; | |
case 6: | |
return 0; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment