The system should show the following top menu. Write a function that simply displays this menu. Sign in Balance Deposit Withdraw Exit We assume that this ATM machine holds account for only 10 people. So, use an array to store client’s account balance. Suppose all accounts start with an initial balance of $1000. With this structure in mind we use array indices (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) as user’s account number (a single digit) and array values as balances. The user must first sign in to use the machine by entering their account number (0, 1, 2, 3,.. 9). If the user enters an incorrect account number the system should give a warning message and display the menu again. User can request account Balance by entering option 2. Write a function to complete the following task: The system displays the current balance. If balance is below $100, the system should display the message “Low Balance”. Then go back to the top menu. If option menu 3, which is Deposit is selected, write a function to compete the task: the system should prompt the user to enter the amount. The ATM machine validates the input by verifying that the input is positive. If not a warning message is displayed “invalid amount”, and the user is prompted to try again, if amount is negative again, the deposit operation is terminated and the top menu is displayed again. If amount is positive the Balance is updated.
I submitted this question earlier and it was stated to be too complex. Below I will post what I have as an answer so far(almost complete).
In C++,
Steps
- The system should show the following top menu. Write a function that simply displays this menu.
- Sign in
- Balance
- Deposit
- Withdraw
- Exit
- We assume that this ATM machine holds account for only 10 people. So, use an array to store client’s account balance. Suppose all accounts start with an initial balance of $1000. With this structure in mind we use array indices (0, 1, 2, 3, 4, 5, 6, 7, 8, 9) as user’s account number (a single digit) and array values as balances. The user must first sign in to use the machine by entering their account number (0, 1, 2, 3,.. 9). If the user enters an incorrect account number the system should give a warning message and display the menu again.
- User can request account Balance by entering option 2. Write a function to complete the following task:
- The system displays the current balance.
- If balance is below $100, the system should display the message “Low Balance”.
- Then go back to the top menu.
- If option menu 3, which is Deposit is selected, write a function to compete the task:
- the system should prompt the user to enter the amount. The ATM machine validates the input by verifying that the input is positive.
- If not a warning message is displayed “invalid amount”, and the user is prompted to try again, if amount is negative again, the deposit operation is terminated and the top menu is displayed again.
- If amount is positive the Balance is updated.
- If option 4, which is Withdraw is selected, write a function to compete the task:
- the ATM machine prompts the user to enter amount, then checks if user has sufficient Balance.
- If the balance is insufficient, then a warning message along with user’s balance is displayed.
- The user is prompted to enter a new amount for a second time, if amount is OK withdraw operation is completed and balance is updated and menu is displayed.
- If balance is still insufficient withdraw operation is terminated and top menu is displayed.
For option exit, write a function that display a “Good Bye” message and exits/log out from user’s account. The ATM machine’s menu is displayed, however this time the next user must sign in by entering his account number (0, 1, 2, …, 10).
Submit code with comments, sample runs for each of the options with at least two different users.
#include<iostream>
using namespace std;
for (int b = 0; b < 10; b++)
b[b] = 1000}
void balance(int b_false) {
cout << "Enter Balance" << b(b_false);
if (b[b_false] <= 100)
cout << "Low Balance" << endl;
}
void deposit(int b_false) {
int amount, count;
count = 0;
neg:count++;
cout << "Enter Deposit" << endl;
cin >> amount;
if ( amount <= 0)
{
if (count == 2)
{
cout << "Invalid Amount" << endl;
}
else
{
cout << "Invalid amount, Please Try Again";
goto neg;
}
}
else
{
b[b_false] = b[b_false] + amount;
cout << "Deposit Success" endl;
}
}
void withdrawal(int b_false) {
int amount, count;
count = 0;
neg:count++;
cout << "Enter Withdrawal Amount" << endl;
cin >> amount;
if (amount <= 0)
{
if (count == 2)
cout << "Invalid Amount, Please Try Again" endl;
goto neg;
}
else if (amount > b[b_false])
{
if (count == 2)
{
cout << "Invalid Amount, Please Try Again" endl;
}
else
{
cout << "Invalid Amount, Please Try Again. Your Balance is=" << b[b_false] endl;
goto neg;
}
}
else
{
b[b_false] = b[b_false] - amount;
cout << "Withdrawal Successful" endl;
}
}
void displayMenu() {
cout << "1.Sign In" << endl;
cout << "2.Balance" << endl;
cout << "3.Deposit" << endl;
cout << "4.Withdrawal" << endl;
cout << "5.Exit" << endl;
}
int main(int b)
{
const int MAX_ACCOUNT = 10;
int amount
(int b) ATM_Balance = 1000;
int selection = 0;
bool log_in_status = false;
int accountNumber;
float accounts[MAX_ACCOUNT];
while (true) {
displayMenu();
cout << "Enter Selection";
cin >> selection;
if (selection < 1 || selection >5) {
cout << "Improper response :( Please Try Again!" << endl;
}
else if (selection == 1) {
cout << "Enter Account Number:";
cin >> accountNumber;
if (accountNumber >= 0 and accountNumber <= 9) {
log_in_status = true;
}
else {
cout << "Account does not exist" << endl;
}
}
else {
if (log_in_status == true) {
switch (selection) {
case 2:
balance(selection);
break;
case 3:
deposit(selection);
break;
case 4:
withdrawal(selection);
break;
default:
cout << "Adios!" << endl;
log_in_status = false;
}
}
else {
}
}
}
}
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 5 images