Write a program that simulates an ATM machine.
Assume an initial balance of 10000. A user may withdraw, deposit, or inquire as many times as he desires. The program will only end when the user chooses to quit the program, otherwise the program should loop and prompt the users for actions.
For security, include an authentication routine that will prompt the user to enter a password. The user is only allowed three attempts to enter the correct password. After the third attempt the program should terminate.
Code:
/*
***Automated Teller Machine with authentication routine***
by MikhaeL Franko T. Mogol
*/
#include<iostream.h>
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;
}//
i'm almost done with my program except for this condition
The program will only end when the user chooses to quit the program, otherwise the program should loop and prompt the users for actions.
pls help me!!!=(