Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <ctype.h>
- #include <stdio.h>
- #include <ios>
- #include <ostream>
- using namespace std;
- template <typename data, typename result>
- bool check (data evaluate, result &value) {
- cout << "Is " << evaluate << " correct? Type 'Yes' or 'No'." << endl;
- CHECKING:
- string response = "Y";
- // getline (cin, response);
- if ((response == "YES") || (response == "Y")) {
- value = false;
- }
- else if ((response == "NO") || (response == "N")) {
- value = true;
- }
- else {
- cout << "You didn't give a proper response... type either a Y or Yes for " << evaluate << " being correct, or a N or No for it being incorrect." << endl;
- goto CHECKING;
- }
- }
- class BankAccount {
- public:
- int balance;
- string owner;
- void get_value () {
- bool boolean = true;
- do {
- cout << "Who owns this Bank Account?\n";
- // getline (cin, owner);
- owner = "Harry";
- check (owner, boolean);
- } while (boolean);
- boolean = true;
- do {
- cout << "How much money does " << owner << " have in their account?\n";
- // cin >> balance;
- balance = 2342135215;
- check (balance, boolean);
- } while (boolean);
- cout << "Excellent.\n";
- }
- int change_value () {
- cout << "Are you withdrawing (W) or depositing (D) today?" << endl;
- CHANGE:
- bool boolean = true;
- string selection;
- int amount;
- // getline (cin, selection);
- selection = "D";
- if ((selection == "D") || (selection == "DEPOSIT")) {
- do {
- cout << "How much are you depositing?" << endl;
- // cin >> amount;
- amount = 342;
- check (amount, boolean);
- } while (boolean);
- balance = balance + amount;
- }
- else if ((selection == "W") || (selection == "WITHDRAW")) {
- WITHDRAW:
- boolean = true;
- do {
- cout << "How much are you withdrawing?" << endl;
- // cin >> amount;
- amount = 234;
- check (amount, boolean);
- } while (boolean);
- balance = balance - amount;
- if (balance < 0) {
- balance = balance + amount;
- cout << "Oops, you tried withdrawing more than what was in your account! Try again... Your balance is " << balance << "." << endl;
- goto WITHDRAW;
- }
- }
- else if ((selection == "C") || (selection == "CANCEL")) {
- boolean = true;
- check (selection, boolean);
- if (boolean == true) {
- goto DONE;
- }
- goto CHANGE;
- }
- else {
- cout << "You didn't make a viable selection.. you need to type either a W to withdraw or a D to deposit. If you would like to cancel this transaction, type C." << endl;
- goto CHANGE;
- }
- DONE:
- return 0;
- }
- };
- int main () {
- BankAccount First;
- First.get_value ();
- First.change_value ();
- }
Advertisement
Add Comment
Please, Sign In to add comment