Вы находитесь на странице: 1из 9

Nod 32

Username:  TRIAL-42971770
   Password:  vh8t68ru23

1uitm

Username: anas
Password: yf^M3SIOWes#

Program for atm system

/*
***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;
}//
Contoh 2

int main()

int password;

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

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


cin>>password;

/* loop through 3 attempts at password */


if (password==123456) {
cout<<"korek!!!\n";
break; }
else
cout<<"Please try again!\n";
if (i == 2) return 0; // if failed 3 times, end program
} /* end password loop */

double balance = 10000;


double withdraw, deposit;
int option;
bool finished = false; // if user selects option 4, 'quit', finished =
true, otherwise finished = false
cout<<"\n";
cout<<" ***MOGOL***\n";
cout<<"*** Automated Teller Machine***"<<endl;
while (!finished) { // repeat until user selects quit
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:
finished = true; // user has selected quit
cout<<"\n***[[[EXIT MODE]]]***\n";

break;

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

}
return 0;
}//
Contoh 3:

/*
***Automated Teller Machine with authentication routine***
by MikhaeL Franko T. Mogol
*/
#include<iostream.h>

int main()

{
double balance = 10000;
double withdraw, deposit;
int option;
int password;

cout <<"enter password:\n";


cin>>password;
if (password==123456)
for (int i=0;i<3;i++)

do{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";
}while(//statement...blah blah, somewhere here,he put some condition,
yah it definitely works!!!

break;
}
else

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

return 0;
}//
Contoh 4

#include<stdio.h>
#include<conio.h>
#include<stdlib.h>
#include<iostream.h>
void main()
{
int choice, a;
float money,m;
clrscr();
void deposite();
void withdraw();
//int func1();

cout<<"Student ID : TATA_12345"<<endl;
cout<<"NAME : RATAN TATA"<<endl;
cout<<"(1) DEPOSITE MONEY"<<endl;
cout<<"(2) WITHDRAW MONEY"<<endl;
cout<<"(3) FIND THE ACCOUNT BALANCE"<<endl;

cout<<"Enter your choice : ";


cin>>choice; /*read the choice*/

switch (choice)
{
case 1:
deposite(); /*to deposite money*/

break;

case 2:
withdraw(); /*to withdraw money*/

break;

case 3: /*to see the balance*/


cout<<endl<<"This facility is not currently available"<<endl;
break;

default: /*if choice is not valid*/

cout<<"ERROR// PLEASE TRY AGAIN";


exit(1);
}
getch();
}

void deposite()
{
float money;
cout<<endl<<"Enter the amount of money to be deposited(dollars.cents):";
cin>>money; /*read the amount to be deposited*/

if(money>0)
{
cout<<endl<<"$"<<money<<" has been deposited in your account"<<endl;
}
else
cout<<endl<<"Please enter valid amount......."<<endl;
}
void withdraw()
{
long int rem,f,t,e;
long int mon;
cout<<"Enter the amount of money to be withdrawn: ";
cin>>mon; /*read the amount to be withdrawn*/

if(mon>=20)
{
if(mon!=30)
{
f=mon/50; /*decides the notes of $50*/
rem=mon%50;
if(rem!=20)
{
if (rem==10||rem==30)
{
f-=1;
rem+=50;
}
}
t=rem/20; /*decides the notes of $20*/
e=rem%20;
if(e==0)
{
cout<<endl<<"Nos. of 50$ note : "<<f;
cout<<endl;
cout<<"Nos. of 20$ note : "<<t<<endl;
cout<<"TOTAL AMOUNT : "<<mon<<endl;
}
else
cout<<endl<<"This amount is not possible... Please try again"<<endl;
}
else /*if amount is not possible*/
{
cout<<endl;
cout<<"This amount is not possible... Please try again"<<endl;
}
}
else
{
cout<<endl;
cout<<"This amount is not possible... Please try again"<<endl;
}
}

Вам также может понравиться