1. Display the following menu to the user: Bank Account Manager 1. Make a deposi
ID: 3536651 • Letter: 1
Question
1. Display the following menu to the user:
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6):
2. The menu should be looped until the user chooses to exit the program, and the program should perform one of the 6 choices based on the user%u2019s input at the menu screen. Once the user finishes with a choice, the menu should be redisplayed prompting the user to make another choice.
INTPUT VALIDATION: The input to the menu should be validated to make sure that the user enters a number 1 %u2013 6. If the user enters any other number, an error message should be displayed and the menu should be redisplayed.
3. OPTION 1: Make a deposit:
a) If the user chooses 1 on the menu screen, then you should prompt the user to enter a deposit into the account.
b) The deposit should be added to the balance in the bank account
c) All deposits should be stored in an output file called "transaction_list.txt" as a positive number.
4. OPTION 2: Make a withdrawal:
a) If the user chooses 2 on the menu screen, then you should prompt the user to enter an amount to withdraw from the account.
b) The withdrawal amount should be subtracted from the balance in the bank account.
c) All withdrawals should be stored in an output file called "transaction_list.txt" as a negative number.
NOTE: The transactions should appear in the output file in the exact order that the user makes the transaction. Please see the sample file.
5. OPTION 3: Show current balance:
a) If the user chooses 3 on the menu screen, then you should display the current balance that is in the account.
6. OPTION 4: Display account report:
a) If the user chooses 4 on the menu screen, then you should display a report about the account which contains the following information. The report should be displayed on the console.
b) the current balance in the account.
c) the number of deposits to the account.
d) the total amount of the deposits to the account.
e) the average deposit amount.
d) the number of withdrawals from the account.
f) the total amount of withdrawals from the account.
g) the average withdrawal from the account.
7. OPTION 5: Print account report:
a) If the user chooses 5 on the menu screen, then you should store all of the information from OPTION 4 in a file called "bank_account_report.txt";
8. OPTION 6: Exit program:
a) If the user chooses 6 on the menu screen then the program should exit
Sample Program Run (Note this is one execution of the program)
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6): 7
Incorrect menu choice!
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6): 1
Enter the deposit amount: 200
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6): 2
Enter the withdrawal amount: 40
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6): 2
Enter the withdrawal amount: 100
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6): 1
Enter the deposit amount: 25
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6): 1
Enter the deposit amount: 35
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6): 3
Current Balance: $620
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6): 4
Current Balance: $620
Number of Deposits: 3
Total Deposit Amount: $260
Average Deposit Amount: $86.6667
Number of Withdrawals: 2
Total Withdrawal Amount: $140
Average Withdrawal Amount: $70
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6): 5
Report sent to file!
Bank Account Manager
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program.
Enter a choice (1-6): 6
Program will now exit!
Press any key to continue ....
transaction_list.txt Would contain
200
-40
-100
25
35
bank_account_report.txt Would contain
Current Balance: $620
Number of Deposits: 3
Total Deposit Amount: $260
Average Deposit Amount: $86.6667
Number of Withdrawals: 2
Total Withdrawal Amount: $140
Average Withdrawal Amount: $70
Explanation / Answer
#include<iostream.h>
#include<fstream.h>
class bank
{
int acc,i,j;
float bal;
public:
bank()
{
bal=500;
i=0;
j=0;
}
void deposite()
{
float a;
cout<<"enter amount to be deposite ";
cin>>a;
bal=bal+a;
i++;
}
void withdraw()
{
float a;
cout<<"enter amount to be withdraw ";
cin>>a;
if(a>bal)
cout<<"insufficent fund";
else
{
bal=bal-a;
j++;
}
}
void print()
{
cout<<"current balance is "<<bal;
}
void display()
{
cout<<"current balance is "<<bal<<" number of times deposite "<<i<<" number of times withdraw "<<j";
}
};
void main()
{
fstream file;
file.open("bank_account_report.txt");
bank a;
int ch=1;
do
{
cout<<"enter your option ";
cout<<"
1. Make a deposit
2. Make a withdrawal
3. Show current balance
4. Display account report
5. Print account report
6. Exit program. ";
cin>>ch;
switch(ch)
{
case 1:
a.deposite();
break;
case 2:
a.withdraw();
break;
case 3:
a.print();
break;
case 4:
a.display();
break;
case 5:
file.write((char*)&a,sizeof(a));
cout<<"file is printed";
break;
case 6:
cout<<"thnk you for using this";
break;
default:
cout<<enter correct option ";
break;
}
} while (ch!=6);
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.