C 언어 ATM 단말기 시뮬레이션 시스템
6370 단어 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();
}
이 내용에 흥미가 있습니까?
현재 기사가 여러분의 문제를 해결하지 못하는 경우 AI 엔진은 머신러닝 분석(스마트 모델이 방금 만들어져 부정확한 경우가 있을 수 있음)을 통해 가장 유사한 기사를 추천합니다:
C 언어 구현 천둥 제거 게임 상세 정보먼저 작은 메뉴를 표시하고 게임을 할지 여부를 선택하십시오.사용자가 종료를 선택하면 프로그램 실행이 끝나고, 사용자가 게임을 선택하면 지뢰 제거 위치 좌표를 입력하라는 메시지가 표시됩니다.사용자가 입력한 좌표가 바둑...
텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
CC BY-SA 2.5, CC BY-SA 3.0 및 CC BY-SA 4.0에 따라 라이센스가 부여됩니다.