Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Use my code below and then change the code create a class that represents a bank account will have an account ID (integer) account name

Use my code below and then change the code create a class that represents a bank account will have

an account ID (integer)

account name (string)

account balance (float)

and then make the output looks like this:

Enter the name: George Enter the balance: 100 Account Menu: 0. Quit Program 1. Display Account Information 2. Add a deposit to an account 3. Withdraw from an account Your choice: 3 Amount to withdraw: 50 Account Menu: 0. Quit Program 1. Display Account Information 2. Add a deposit to an account 3. Withdraw from an account Your choice: 1 Account ID: 0 Name: George Balance: $50.00

;-----------------------------------------------------------------------------------

code is

#include

using namespace std; int display_menu() { int choice; cout << " BANK " << endl; cout << " 1.Display Balance" << endl; cout << " 2.Make a Deposit" << endl; cout << " 3.Make a Withdraw" << endl; cout << " 0.Exit" << endl; cout << " Enter your choice: >"; do { cin >> choice; if (choice < 0 || choice>3) { cout << " Wrong input!!please enter valid operation number" << endl; } } while (choice < 0 || choice>3); return choice;

}

double deposit_amount(double balance, double dep_amount) { return (balance + dep_amount); }

double withdrawal_amount(double balance, double with_amount) { if (with_amount > balance) return balance; else return (balance - with_amount); } void display_balance(double balance, string name) { cout << " Account Name: " << name; cout << " The current account balance is $" << balance << endl; }

double check_postive() { double number = 1.00;//some random number; cout << "Enter a positive number : "; do { if (number < 0) { cout << " Please enter a valid amount : "; } cin >> number;

} while (number < 0); return number; }

int main() { string name; double balance = 0; cout << " Enter your Name: >"; cin >> name; cout << " Enter your Balance: >"; cin >> balance; int choice = 5;//some random value double amount; while (choice != 0) { choice = display_menu(); if (choice == 1) display_balance(balance, name); else if (choice == 2 || choice == 3) amount = check_postive(); if (choice == 2) balance = deposit_amount(balance, amount); if (choice == 3) balance = withdrawal_amount(balance, amount);

}

return 0; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

Have I incorporated my research into my outline effectively?

Answered: 1 week ago