Need help with homework

For this assignment, write a program that will simulate an ATM for PCME Bank.

The user will be displayed a menu with the different banking options:

C)hecking
S)avings
B)alance display
M)onthly Maintenance
After the option has been processed (detailed below), the user should be asked if they would like to apply another transaction. A value of 'Y' or 'y' indicates they would like to continue.

Before exiting the program, display a "thank you" message to the customer.

Checking

If the user selects the checking option ('C' or 'c'), they will be given the option to withdraw money from the account ('W' or 'w') or make a deposit to the account ('D' or 'd').

In the case of a withdrawal, the user should be prompted for the amount they would like to withdraw and that amount should be compared to the current balance for the checking account. If there is enough money in the account, the withdrawal should be processed by subtracting the amount from the balance. If there is not enough money in the account, an error message that includes the requested amount and the balance should be displayed.

In the case of a deposit, the user should be prompted for the amount they would like to deposit. If the value is positive, it should be added to the checking account balance. If it's negative, an error message that includes the negative amount should be displayed.

In the case of anything other than a withdrawal or deposit, display an error message that includes the invalid choice.

Savings

If the user selects the savings option ('S' or 's'), they will be given the option to withdraw money from the account ('W' or 'w') or make a deposit to the account ('D' or 'd').

In the case of a withdrawal, the user should be prompted for the amount they would like to withdraw and that amount should be compared to the current balance for the savings account. If there is enough money in the account, the withdrawal should be processed by subtracting the amount from the balance. If there is not enough money in the account, an error message that includes the requested amount and the balance should be displayed.

In the case of a deposit, the user should be prompted for the amount they would like to deposit. If the value is positive, it should be added to the savings account balance. If it's negatice, an error message that includes the negative amount should be displayed.

In the case of anything other than a withdrawal or deposit, display an error message that includes the invalid choice.

Balance Display

If the user selects the balance display ('B' or 'b'), display the current balance for both the checking and savings accounts.

Monthly Maintenance

If the user selects the monthly maintenance option ('M' or 'm'), they should be prompted for the password for their account. If the password "makechange" is specified, both accounts will be updated. For the savings account, the balance should be increased by a monthly interest rate. The annual rate of interest on the savings account is 5% so the monthly rate is 1/12th of the annual rate. The checking account balance should have a maintenance fee of $5.00 deducted.

After both of the accounts have been updated, the checking account fee, updated checking account balance, amount of monthly interest added to the savings account, and the updated savings account balance should all be displayed.

If an invalid password is entered (ie. something other than "makechange"), display an invalid password error message.

Anything Else

In the case of anything other than checking, savings, balance display, or monthly maintenance, display an error message that includes the invalid choice.

Processing Requirements:



White space and indentation should be used to make your code easily readable. See the documentation standards on the course webpage.

The program must create and use at least two symbolic constants: one should represent the checking account maintenance fee of 5.00, while the other should represent the monthly interest rate for the savings account (1/12th of 5%).

The initial balance for both the checking and savings accounts should be $0.00.
#include <iostream>
#include <iomanip>

using namespace std;

int main()

{

int password;

for (int i=0;i<3;i++)

{cout <<"enter password:\n";
cin>>password;

if (password==123456)
{cout<<"korek!!!\n";

double balance = 10000;
double withdraw, deposit;
int option;
cout<<"\n";
cout<<" ***MOGOL***\n";
cout<<"*** Automated Teller Machine***"<<endl;
cout<<"Choose a Transaction:\n";
cout<<"\n";
cout<<"[1] Inquire Balance \n"
<<"[2] Withdraw \n"
<<"[3] Deposit \n"
<<"[4] Quit \n"
<<"\n"
<<"Enter Option:";
cin>>option;

switch(option)
{
case 1:
cout<<"\n[[[BALANCE INQUIRY]]]\n";
cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);
cout<<"\n Your current balance is $"<<balance<<endl;
break;
case 2:
cout<<"\n[[[WITHDRAW]]]\n";
cout<<"Enter amount: $";
cin>>withdraw;

balance = balance - withdraw;

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout<<"You withdrew $"<<withdraw<<endl;
cout<<"Your remaining balance is $"<<balance<<endl;
continue;
case 3:
cout<<"\n[[[DEPOSIT]]]\n";
cout<<"Enter amount: $";
cin>>deposit;

balance = balance + deposit;

cout.setf(ios::fixed);
cout.setf(ios::showpoint);
cout.precision(2);

cout<<"You deposited $"<<deposit<<endl;
cout<<"Your new balance is $"<<balance<<endl;
continue;
case 4:
cout<<"\n***[[[EXIT MODE]]]***\n";

break;


default:
cout<<"\n That is an invalid option \n";
}






break;
}
else


cout<<"Pls try again!!!\n";}

return 0;
}//

This is what i got so far.
Why does it loop through three times?

instead of the for loop, try a do..while(...) loop:

1
2
3
4
5
6
7

do{

...


}while(option != 4);


then place the option variable declaration above the 'do' statement.

Topic archived. No new replies allowed.