!!!Please do exactly like this when the program runs this all should include also the * when typing the PIN!!!
AUTOMATED TELLER MACHINE
Screen/layout
MAD AUTOMATED TELLER MACHINE IS ONLINE
INPUT YOUR 6 DIGIT PIN ******
ENTER[Y/N]: Y
(default PIN is mad123; if correct go to main screen otherwise display the message "WRONG PIN". On the 3rd wrong attempt the prog. should exit)
[C]HECK BALANCE
[D]EPOSIT CASH
[W]ITHDRAW CASH
C[H]ANGE PIN
TRANSACTION: [C|D|W|H]: C
YOUR CURRENT BALANCE IS:
Php 0.00
TRANSACTION: [C|D|W|H]: D
INSERT YOU CASH
Php 15,000.00
Transaction [C|D|W|H]: W
INPUT THE AMOUNT OF WITHDRAWAL
Php 20,000.00
CASH NOT ENOUGH, TRY AGAIN
INPUT THE AMOUNT OF WITHDRAWAL
Php 5,000.00
TRANSACTION: [C|D|W|H]: H
INPUT YOUR CURRENT PIN ******
INPUT YOUR NEW PIN ******
VERIFY YOUR NEW PIN ******
ENTER[Y/N]: Y
#include<iostream>
#include<conio.h>
#include<cstring>
using namespace std;
class ATM
{
double amount;
char PIN[7];
public:
ATM(double _amount, char _PIN[6]):amount(_amount)
{
int i;
for (i = 0; i < 6; i++)
{
PIN[i] = _PIN[i];
}
PIN[i] = '\0';
}
void CheckBalance()
{
cout << "\nYOUR CURRENT BALANCE IS: \nPhp " << amount;
}
void DepositCash()
{
double insAmount;
cout << "\nINSERT YOUR CASH: \nPhp ";
cin >> insAmount;
amount += insAmount;
}
void WithdrawCash()
{
double insAmount;
bool done = false;
do
{
cout << "\nINPUT THE AMOUNT OF WITHDRAWAL: \nPhp ";
cin >> insAmount;
if (insAmount > amount)
{
cout << "CASH NOT ENOUGH, TRY AGAIN";
}
else
{
amount -= insAmount;
done = true;
}
} while (!done);
}
void ChangePIN()
{
cout << "\nINPUT YOUR CURRENT PIN ";
char pin[7];
int i;
for (i = 0; i < 6; i++)
{
pin[i] = _getch();
_putch('*');
}
pin[i] = '\0';
if (strcmp(pin, PIN) != 0)
{
cout << "\nWRONG PIN!\n";
}
else
{
char ch;
do
{
cout << "\nINPUT YOUR NEW PIN ";
for (i = 0; i < 6; i++)
{
pin[i] = _getch();
_putch('*');
}
pin[i] = '\0';
cout << "\nVERIFY YOUR NEW PIN ";
char NEWpin[7];
for (i = 0; i < 6; i++)
{
NEWpin[i] = _getch();
_putch('*');
}
NEWpin[i] = '\0';
if (strcmp(pin, NEWpin) != 0)
{
cout << "\nWRONG NEW PIN!\n";
}
else
{
for (i = 0; i < 6; i++)
{
PIN[i] = pin[i];
}
}
cout << "\nENTER[Y/N]:";
cin >> ch;
if (ch == 'Y')
{
break;
}
} while (true);
}
}
};
void Menu()
{
cout << "[C]HECK BALANCE\n"
<< "[D]EPOST CASH\n"
<< "[W]ITHDRAW CASH\n"
<< "C[H]ANGE PIN\n"
<< "[E]XIT PROGRAM\n";
}
int main()
{
ATM atm(0,"mad123");
char pin[7];
char ch;
int attempt = 0;
do
{
cout << "******MAD AUTOMATED TALLER MACHINE IS ONLINE******\n";
cout << "INPUT YOUR 6 DIGIT PIN ";
int i;
for (i = 0; i < 6; i++)
{
pin[i] = _getch();
_putch('*');
}
pin[i] = '\0';
cout << "\nENTER[Y/N]:";
cin >> ch;
if (ch == 'Y')
{
if (strcmp(pin, "mad123") != 0)
{
cout << "WRONG PIN!\n";
attempt++;
cout << "You have only " << 3 - attempt << " attempts left!\n";
}
else
{
break;
}
}
} while (attempt<3);
if (attempt == 3)
return -1;
Menu();
do
{
cout<<"\nTRANSACTION: [C|D|W|H]: ";
cin >> ch;
switch (ch)
{
case 'C':
{
atm.CheckBalance();
break;
}
case 'D':
{
atm.DepositCash();
break;
}
case 'W':
{
atm.WithdrawCash();
break;
}
case 'H':
{
atm.ChangePIN();
break;
}
}
} while (ch != 'E');
}
Comments
Leave a comment