#include <stdio.h>
#define PASSWORD 9527
#define RMB 100000
#define DORROR 10000
void exit (int x)
{
while (x! = 0)
{
printf ("0:cancle\n");
scanf ("%d", &x);
}
Return
}
void Take (int choice,int a[])
{
int x;
while (choice)
{
if (choice = = 1)
{
System ("CLS");
printf ("You want-take Money:¥");
scanf ("%d", &x);
A[0]-= x;
printf ("success! Your rmb:%d\n ", a[0]);
Exit (choice);
}
if (choice = = 2)
{
System ("CLS");
printf ("You want-take money:$");
scanf ("%d", &x);
A[1]-= x;
printf ("success! Your rmb:%d\n ", a[1]);
Exit (choice);
}
System ("CLS");
printf ("Pls input the sort of money which want to take:\n");
printf ("1:rmb 2:dollor 0:cancle\n");
scanf ("%d", &choice);
}
Return
}
void Save (int choice,int a[])
{
int x;
while (choice)
{
if (choice = = 1)
{
System ("CLS");
printf ("You want to save Money:¥");
scanf ("%d", &x);
A[0] + = x;
printf ("success! Your rmb:%d\n ", a[0]);
Exit (choice);
}
if (choice = = 2)
{
System ("CLS");
printf ("You want to save money:$");
scanf ("%d", &x);
A[1] + = x;
printf ("success! Your rmb:%d\n ", a[1]);
Exit (choice);
}
System ("CLS");
printf ("Pls input the sort of money which want to save:\n");
printf ("1:rmb 2:dollor 0:cancle\n");
scanf ("%d", &choice);
}
Return
}
void examine (int choice,int a[2])
{
while (choice! = 0)
{
if (choice = = 1)
{
System ("CLS");
printf ("rmb:%d\n", a[0]);
Exit (choice);
}
else if (choice = = 2)
{
System ("CLS");
printf ("dollor:%d\n", a[1]);
Exit (choice);
}
System ("CLS");
printf ("Pls input the sort of money which-want to search for:\n");
printf ("1:rmb 2:dollor 0:cancle\n");
scanf ("%d", &choice);
}
Return
}
void Main ()
{
int i,password,choice,choice1,choice2,choice3;
int A[2]={rmb,dorror};
printf ("********************************************************\n");
printf ("* ATM *\n");
printf ("* Welcome to Feneration Bank *\n");
printf ("*---------------------------------------*\n");
printf ("* Owner:excalibur Version number:1.0.1 *\n");
printf ("*---------------------------------------*\n");
printf ("* telephone:028-81484128 *\n");
printf ("*-----------------------*\n");
printf ("* *\n");
printf ("* If you had any QUESTION,PLS does not contact with us *\n");
printf ("********************************************************\n");
printf ("Pls insert your card and input password:");
scanf ("%d", &password);
for (i = 0;i < 2;i++)
{
if (password = = password)
{
Break
}
printf ("Your password is wrong,pls input again:");
scanf ("%d", &password);
}
if (i = = 2)
{
printf ("Sorry,you has input 3 times wrong password!\n");
printf ("Your money had been confiscated!\n");
printf ("Pls do not contact with us! \ n ");
Return
}
System ("CLS");
printf ("Pls input your requirement:\n");
printf ("1:examine balance 2:saving 3:take out 0:cancle\n");
scanf ("%d", &choice);
while (choice! = 0)
{
if (choice = = 1)
{
System ("CLS");
printf ("Pls input the sort of money which-want to search for:\n");
printf ("1:rmb 2:dollor 0:cancle\n");
scanf ("%d", &choice1);
Examine (choice1,a);
}
if (choice = = 2)
{
System ("CLS");
printf ("Pls input the sort of money which want to save:\n");
printf ("1:rmb 2:dollor 0:cancle\n");
scanf ("%d", &choice2);
Save (Choice2,a);
}
if (choice = = 3)
{
System ("CLS");
printf ("Pls input the sort of money which want to take:\n");
printf ("1:rmb 2:dollor 0:cancle\n");
scanf ("%d", &choice3);
Take (Choice3,a);
}
System ("CLS");
printf ("1:examine balance 2:saving 3:take out 0:cancle\n");
scanf ("%d", &choice);
}
}
C-language after ATM first attempt