C 언어 ATM 단말기 시뮬레이션 시스템

#include 
#include 
#include 
#include 
#include 
#include 
#define N 20
void Initial();				//     
void BuildUser();			 //       
int UserLogin();				//      
void AdminLogin();				//       
void Menu(int n);			  //    
void ChangePassword();			   //    
typedef struct User			      //       
{
    char UserID[N];              //  ID
    char Name[N];                  //  
    char UserPassword[N];		   //    
	float money;				      //      
	char time[N];					  //            
}USERDATA;
typedef struct D				  //         
{
	char id[N];
	char o;
	char money;
	char balance;
	char tim[N];
}PDATA;
float MoneySave(struct User *p);				//    
float DrawMoney(struct User *p);				//    
float Trans(struct User *p);					//    
void Balance();									//    
USERDATA userdata[500];
int main()
{
    system("cls");						//  
	system("title ATM      ");
	system("color 0b");
	Initial();
	//printf("  ");
	return 0;
}

void Initial()
{
	system("cls");
	int a,ret,b;
	do{                      //     1 2,    

	printf("



"); printf(" ATM

"); printf(" -------------------------------------------------

"); printf(" :

"); printf(" -------------------------------------------------

"); //printf(" _________________________________________________
"); printf(" 1


"); //printf(" _________________________________________________
"); printf(" 2


"); printf(" 3


"); printf(" -------------------------------------------------
"); printf("\t\t\t\t\t\t\t"); system("date /t"); printf("\t\t\t\t\t\t\t"); system("time /t"); do{ // , //printf(" :
"); printf(" ------------"); scanf("%d",&a); switch(a) // 1,2 。 { case 1: b=1;break; case 2: b=1;break; case 3: exit(0);break; default: printf(" "); printf(" , 。
");break; } getchar(); }while(b!=1); if(a==1) { ret=UserLogin(); // Menu(ret); // ret=1; } else if(a==2) { system("cls"); // AdminLogin(); ret=1; } }while(ret!=1); } int UserLogin() { char a[N],b[N]; FILE *fp; if((fp=fopen("iddata.txt","a+"))==NULL) // { printf("
"); exit(0); } int i=0,j,k=0,s; do{ fscanf(fp,"%s%s%s%f",&userdata[i].Name,&userdata[i].UserID,&userdata[i].UserPassword,&userdata[i].money);// i++; }while(!feof(fp)); // fclose(fp); // system("cls"); printf("




:"); //printf(" "); gets(a); printf("

:"); //printf(" "); gets(b); for(j=0;jmoney+=money; printf("\t\t\t"); printf(" %.2f , 。
",money); printf(" "); getch(); return money; } float DrawMoney(struct User *p) { float money; int s=0; printf("
\t\t\t :"); // do{ scanf("%f",&money); if(money>p->money) { printf("
\t\t\t
"); printf("
\t\t\t , 。"); getch(); return 0; } if(money>2500) { printf("
\t\t\t 2500 , :");// 2500 } if((int)money%50!=0) { printf("
\t\t\t 50 100 RMB。

\t\t\t :"); } }while(money>2500||(int)money%50!=0); p->money-=money; printf("
\t\t\t %.2f 。 。
",money); getch(); return -money; } float Trans(struct User *p) { FILE *fp; char a[N]; float money; printf("
\t\t\t :"); re: scanf(" %s",a); char path[30]="G:\\1\\ATM\\private_record\\",suffix[]=".txt"; strcat(path,a); strcat(path,suffix); if((fp=fopen(path,"r+"))==NULL) { fp=fopen(path,"w+"); printf("
\t\t\t , :"); goto re; } else { printf("
\t\t\t :"); scanf("%f",&money); while(money>p->money||money<=0) { if(money>p->money) { printf("
\t\t\t
"); printf("
\t\t\t 。"); printf("\t\t "); getch();return 0; break; } } p->money-=money; printf("
\t\t\t %.2f ,
",money); fclose(fp); printf(" "); getch(); return -money; } } void ChangePassword() { char str1[7],str2[7]; do{ printf("
\t\t\t , 6 :"); scanf("%s",str1); printf("
\t\t\t :"); scanf("%s",str2); if(strcmp(str1,str2)!=0) { printf("
\t\t\t , :"); } }while(strcmp(str1,str2)!=0); printf("
\t\t\t , 。"); getch(); }

좋은 웹페이지 즐겨찾기