Question
Below is my code, I just need it to ask to promt another input user name, and the account information will be corresponding to each
Below is my code, I just need it to ask to promt another input user name, and the account information will be corresponding to each id, and when I want deposit or withdraw it will take user id and information and then make balance change for specific input user id.
#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) { 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() { double balance = 6000.00; int choice = 5;//some random value double amount; while (choice != 0) { choice = display_menu(); if (choice == 1) display_balance(balance); 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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started