真实的国产乱ⅩXXX66竹夫人,五月香六月婷婷激情综合,亚洲日本VA一区二区三区,亚洲精品一区二区三区麻豆

成都創(chuàng)新互聯(lián)網(wǎng)站制作重慶分公司

C語(yǔ)言的函數(shù)設(shè)計(jì)ATM C語(yǔ)言函數(shù)設(shè)計(jì)

C語(yǔ)言設(shè)計(jì)銀行賬戶模擬程序

能傳附件嗎?不知道怎么傳。我就貼給你吧。

我們提供的服務(wù)有:網(wǎng)站制作、成都網(wǎng)站設(shè)計(jì)、微信公眾號(hào)開(kāi)發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、穆棱ssl等。為上千家企事業(yè)單位解決了網(wǎng)站和推廣的問(wèn)題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的穆棱網(wǎng)站制作公司

#includeiostream

#includestring

#includefstream

using namespace std;

class account //atm賬戶類

{

private:

string CardNum,Psw; //卡號(hào)、密碼

float Balance;

public:

friend class ATM; //atm為友元

/*void get_cardnum();

void get_psw();

void get_balance();*/

account(){}//---------------------here

account(string num,string passwd,float balance); //構(gòu)造函數(shù)

void Write();

};

class ATM //atm機(jī)類

{

private:

int times;

account *ac;

public:

ATM(); void load( account *act ); //裝入賬戶信息

void welcome(); //初始?xì)g迎信息

bool check_passwd( string pwd ); //驗(yàn)證當(dāng)前賬戶信息的密碼

void change_psw(); //修改密碼

void get_money(); //取錢(qián)

float check_balance(); //查賬

void tran(); //轉(zhuǎn)賬

void exit(); //退卡

void function_show(); //顯示功能菜單

void lock(); //鎖定賬戶

};

/*

* account::account( string num, string passwd, float balance )

* account類構(gòu)造函數(shù)

* 用途: 使用給定的賬號(hào)密碼等信息初始化一個(gè)account對(duì)象

* 參數(shù): string num 賬號(hào)

* string passwd 密碼

* float balance

*/

account::account( string num, string passwd, float balance )

{

CardNum = num;

Psw = passwd;

Balance = balance;

}

//atm類構(gòu)造函數(shù)

/*account::get_cardnum()

{

return CardNum;

}

account::get_psw()

{

return Psw;

}

account::get_balance()

{

return Balance;

}*/

void account::Write()

{

ofstream outfile("atm.txt",ios::binary);//-----------------here

outfile.write((char *)(this),sizeof(account));//-------------here

outfile.close();

}

ATM::ATM()

{

}

/*

* void ATM::load( account *act )

* ATM類裝入賬戶信息函數(shù)

* 用途: 載入指定的account對(duì)象,模擬atm插卡過(guò)程

* 參數(shù): account *act 要載入的account對(duì)象指針

*/

void ATM::load( account *act )

{

ac = act;

}

/*

* void ATM::welcome()

* ATM類顯示初始?xì)g迎信息函數(shù)

* 用途: 顯示歡迎信息,提示密碼輸入并驗(yàn)證

* 參數(shù): 無(wú)

*

*/

void ATM::welcome()

{

times = 0; //記錄密碼輸入錯(cuò)誤次數(shù)

cout "Welcome to use the China Bank ATM!" endl;

string pwd; //這一個(gè)語(yǔ)句應(yīng)該上移的,一般來(lái)說(shuō)數(shù)據(jù)的定義和初始化一塊寫(xiě)在開(kāi)頭,下面才是各種操作的語(yǔ)句

while( times 3 )

{

cout "Please enter the password: " endl;

cin pwd;

if( !check_passwd( pwd ) )

{

cout "The password you entered is wrong, please enter again" endl;

times++;

}

else

{

function_show();

break;

}

}

if( times = 3 )

lock(); //輸入密碼錯(cuò)誤次數(shù)超過(guò)(等于)3次,鎖定賬戶

}

bool ATM::check_passwd( string pwd )

{

if( pwd == ac-Psw )

return true;

else

return false;

}

void ATM::function_show()

{

int n;

cout "(1) Change Password" endl;

cout "(2) Get Money" endl;

cout "(3) Check Balance" endl;

cout "(4) Transfer accounts" endl;

cout "(5) Exit" endl;

cin n;

while(n != 1 n != 2 n != 3 n != 4 n != 5) //這樣就可以完全限制用戶的輸入

{

cout "Please enter the right number" endl;

cin n;

}

switch( n )

{

case 1:

change_psw();

break;

case 2:

get_money();

break;

case 3:

cout check_balance() endl;

break;

case 4:

tran();

break;

case 5:

exit();

break;

}

}

void ATM::lock()

{

cout "Sorry! Your card has been confiscated!" endl;

exit();

}

void ATM::change_psw()

{

string old_psw, new_psw1, new_psw2;

int t = 0 ;

while( t 3 )

{

cout "Please enter the old password: ";

cin old_psw;

if( !check_passwd( old_psw ) )

{

cout "The password you enter is wrong, please enter again" endl;

t++;

}

else

{

cout "Please enter the new password: ";

cin new_psw1;

cout "Please enter the new password again: ";

cin new_psw2;

if( new_psw1 == new_psw2 )

{

ac - Psw = new_psw2;

cout "You have change your password successfully!" endl;

break;

}

else

cout "Sorry, entered passwords do not match! " endl;

}

}

//}//----------------------here

if( t = 3 )

{

cout "Sorry, you have inputed the wrong password for three times and more! " endl;

}

}

void ATM::get_money()

{

float money;

cout "Please enter the amount of money you want to get: " endl;

cin money;

while( money ac - Balance)

{

cout "Your balance is not enough, please enter again" endl;

cin money;

}

ac - Balance = ac - Balance - money;

}

float ATM::check_balance()

{

return ac - Balance;

}

void ATM::tran()

{

account a[5];

string cn;

float m;

cout"please enter the cardnum of the account you want to transfer money to"endl;

cincn;

ifstream infile("atm.txt",ios::binary);

infile.seekg(0,ios::beg);

for(int i=0;i5;i++)

{

infile.read((char *)(a[i]),sizeof(a[i]));

}

for(int j=0;j5;j++)

{

if(cn==a[i].CardNum)

{

cout"please enter the amount of money"endl;

cinm;

while(mac-Balance)

{

cout"there is no enough money in your account,please enter again"endl;

cinm;

}

ac-Balance=ac-Balance-m;

a[i].Balance=a[i].Balance+m;

ofstream outfile("atm.txt",ios::binary);

outfile.seekp(i*sizeof(a[0]),ios::beg);

outfile.write((char *) a[i],sizeof(a[i]));

}

}

if(j=5)

{

cout"the account doesn't exit"endl;

}

}

void ATM::exit()

{

cout "Please take your card!" endl;

}

int main()

{

account a[5]={account("10001","1111",5000.0f),account("10002","2222",10000.0f),account("10003","3333",15000.0f),

account("10004","4444",20000.0f),account("10005","5555",25000.0f)};

account temp( "10001", "1111", 5000.0f );

ATM atm;

atm.load( temp );

atm.welcome();

return 0;

}

怎樣用c語(yǔ)言編寫(xiě)ATM系統(tǒng)

真正的ATM系統(tǒng)不可能只是用C語(yǔ)言編寫(xiě)的,它應(yīng)該是一套完整獨(dú)立的系統(tǒng),核心代碼更機(jī)密,不會(huì)輕易的泄露。

C語(yǔ)言可以寫(xiě)一個(gè)類似于ATM系統(tǒng)的框架,用以模擬ATM機(jī)上的各種操作。

框架代碼如下:

#includeiostream.h??

#includestdio.h??

int?main()???

{??

int?choice?=-?1;???

while(1)?{??

printf("請(qǐng)選擇\n1.login\t2.regist\n");??

scanf("%d",?choice);??

switch(choice)?{??

case?1:??

login();??

break;??

case?2:??

regist();??

break;??

default:??

printf("輸入有誤,重新輸入\n");??

break;??

}??

}??

return?0;

}??

void?login()?{??

printf("IN?LOGIN\n");??

int?flag?=?-1;??

int?X?=?-1;??

printf("輸入賬戶和密碼\n");??

flag?=?search();??

if(falg?==?1)?{??

printf("存在,進(jìn)入主頁(yè)面\n");??

X?=?menu();??

if(X?==?1)??

return;??

}??

else?if(flag?==?0)?{??

printf("賬戶或密碼錯(cuò)誤\n");??

return;???????

}??

}??

int?regist()?{??

printf("IN?REGIST\n");??

return?1;??

}??

int?menu()?{??

printf("IN?MENU\n");??

int?key?=?-1;??

int?N?=?-1;??

while(1)?{??

printf("請(qǐng)選擇業(yè)務(wù):1.refer\t2.deposit\t3.withdraw\t4.transfer\t5.resetPW\t6.退出\n");??

scanf("%d",?key);??

switch(key)?{??

case?1:??

N?=?refer();??

break;??

case?2:??

N?=?deposit();??

break;??

case?3:??

N?=?withdraw();??

break;??

case?4:??

N?=?transfer();??

break;??

case?5:??

N?=?resetPW();??

break;??

case?6:??

N?=?6;??

return?1;??

break;??

default:??

printf("輸入有誤,重新選擇:\n");???

break;??

}??

if(N%2?==?0)?{??

printf("Error!\n");??

}???

}??

}??

int?refer()?{??

printf("IN?REFER\n");??

//輸出余額???

return?1;??

}??

int?deposit()?{??

printf("IN?DEPOSIT\n");??

//存錢(qián)???

return?3;??

}??

int?withdraw()?{??

printf("IN?WITHDRAW\n");??

//取錢(qián)???

return?5;??

}??

int?transfer()?{??

ptintf("IN?TRANSFER\n");??

//轉(zhuǎn)賬???

return?7;??

}??

int?resetPW()?{??

prtintf("IN?RESETPW\n");??

//重設(shè)密碼???

return?9;??

}

用c語(yǔ)言編寫(xiě)ATM的程序,實(shí)現(xiàn)開(kāi)戶、存款、取款、查詢余額、轉(zhuǎn)賬的業(yè)務(wù)邏輯。

#include stdio.h

#include stdlib.h

#include conio.h

#include string.h

void regist();

void login();

void quite();

void inputpassword(char mima[]);

void service();

struct bank

{

char name[20];

char password[7];

int account;

double money;

}kehu;

int find;

int a[10];

struct bank one;

FILE *fp;

void main()

{

int i;

int t=1;

for(i=0;i100;i++)

{

printf("\t\t\t\t\t\t歡迎使用青軟ATM系統(tǒng)\n");

printf("\t\t\t\t\t\t正在進(jìn)入主界面,請(qǐng)稍等");

int j;

for(j=1;jt;j++)

{

printf(".");

}

t++;

if(t==10)

{

t=1;

}

printf("\n\t\t\t\t\t\t%d%%",i);

system("cls");

}

while(1)

{

printf("\t\t\t\t\t\t服務(wù)類型: \n");

printf("\t\t\t\t\t\t[a]: 用戶注冊(cè)\n");

printf("\t\t\t\t\t\t[b]: 用戶登錄\n");

printf("\t\t\t\t\t\t[c]: 退出系統(tǒng)\n");

printf("\t\t\t\t\t\t請(qǐng)選擇服務(wù): ");

fflush(stdin);

char xz;

scanf("%c",xz);

if(xz=='a'||xz=='A')

{

regist();

} else if (xz=='b'||xz=='B')

{

login();

} else if(xz=='c'||xz=='C')

{

quite();

} else

{

printf("輸入有誤,請(qǐng)重新輸入");

}

getch();

system("cls");

}

}

void inputpassword(char mima[])

{

int i=0;

char ch;

while(1)

{

ch=getch();

if(ch!='\r')

{

if(ch!='\b'){

mima[i]=ch;

i++;

printf("*");

}else{

if(i0){

i--;

printf("\b \b");

}

}

}else{

break;

}

}

mima[i]='\0';

printf("\n");

}

void regist()

{

fp=fopen("atm.txt","ab+");

if(fp==NULL)

{

printf("\n\t\t\t文件打開(kāi)失敗!");

return;

}

system("cls");

printf("\t\t\t現(xiàn)在執(zhí)行的是注冊(cè)函數(shù)的使用\n");

printf("\t\t請(qǐng)輸入用戶名: ");

fflush(stdin);

gets(kehu.name);

char password1[7];

while(1)

{

while(1)

{

printf("\n\n\t\t請(qǐng)輸入密碼:");

fflush(stdin);

inputpassword(kehu.password);

int n=strlen(kehu.password);

if(n==6)

{

break;

}else

{

printf("\n\t\t密碼必須為6位!");

}

}

printf("\n\t\t請(qǐng)輸入正確密碼!: ");

fflush(stdin);

inputpassword(password1);

if(strcmp(kehu.password,password1)==0)

{

break;

}else{

printf("\n\n\t\t兩次密碼必須相同!");

}

}

rewind(fp);

struct bank k;

if(fread(k,sizeof(struct bank),1,fp)==1)

{

fseek(fp,-sizeof(k),2);

fread(k,sizeof(k),1,fp);

kehu.account=k.account+1;

}else{

kehu.account=20170001;

}

kehu.money=0;

fseek(fp,0,2);

fwrite(kehu,sizeof(struct bank),1,fp);

fclose(fp);

printf("\n\n\t\t開(kāi)戶成功! ");

printf("\n\t\t您的賬號(hào)為%d!",kehu.account);

printf("\n\t\t現(xiàn)在請(qǐng)您重新登錄!");

}

void searchmoney()

{

system("cls");

printf("您現(xiàn)在使用的是查詢余額功能: \n");

printf("\n\n\t\t您的余額是%0.2lf",one.money);

}

void savemoney()

{

system("cls");

double inmoney;

printf("請(qǐng)您選擇您要存款的金額 \n");

scanf("%lf",inmoney);

int q;

int r=1;

for(q=0;q100;q++)

{

int w;

for(w=1;wr;w++)

{

printf(".");

}

r++;

if(r==10)

{

r=1;

}

printf("\n\t\t\t\t\t\t正在存款%d%%",q);

system("cls");

}

one.money=one.money+inmoney;

fseek(fp,-sizeof(one),1);

fwrite(one,sizeof(one),1,fp);

printf("\n\n\t\t\t\t\t\t您已存款成功!");

}

void withdrawalmoney()

{

system("cls");

double outputsomemoney;

printf("請(qǐng)您選擇您要取款的金額 \n");

scanf("%lf",outputsomemoney);

if(one.moneyoutputsomemoney){

printf("您的余額已不足,請(qǐng)您注意!");

}else {

int q;

int r=1;

for(q=0;q100;q++)

{

int w;

for(w=1;wr;w++)

{

printf(".");

}

r++;

if(r==10)

{

r=1;

}

printf("\n\t\t\t\t\t\t正在取款%d%%",q);

system("cls");

}

one.money=one.money-outputsomemoney;

fseek(fp,-sizeof(one),1);

fwrite(one,sizeof(one),1,fp);

printf("\n\n\t\t\t\t\t\t您已取款成功!請(qǐng)點(diǎn)清鈔票!");

printf("\n\n\t\t\t\t\t\t您現(xiàn)在的余額為%lf",one.money);

}

}

void transfermoney()

{

system("cls");

int duifang;

int qian;

fflush(stdin);

printf("\n\n\n\t\t您現(xiàn)在使用的是轉(zhuǎn)賬功能");

printf("\n\t\t\t請(qǐng)輸入您要轉(zhuǎn)賬的賬戶:");

scanf("%d",duifang);

int n=ftell(fp);

rewind(fp);

int flag=0;

struct bank temp;

while(fread(temp,sizeof(temp),1,fp)==1)

{

if(temp.account==duifang)

{

flag=1;

break;

}

}

if(flag==1)

{

printf("請(qǐng)輸入轉(zhuǎn)賬金額:");

scanf("%d",qian);

if(one.money=qian)

{

int q;

int r=1;

for(q=0;q100;q++)

{

int w;

for(w=1;wr;w++)

{

printf(".");

}

r++;

if(r==10)

{

r=1;

}

printf("\n\t\t\t\t\t\t正在轉(zhuǎn)賬,請(qǐng)稍后!%d%%",q);

system("cls");

}

temp.money=temp.money+qian;

fseek(fp,-sizeof(temp),1);

fwrite(temp,sizeof(temp),1,fp);

one.money=one.money-qian;

fseek(fp,n-sizeof(one),0);

fwrite(one,sizeof(one),1,fp);

printf("\n\t\t\t\t轉(zhuǎn)賬成功!");

}else{

printf("\n\t\t\t\t您的余額已不足!");

}

}

}

void xiugai(){

system("cls");

printf("\n\n\t\t 現(xiàn)在進(jìn)行的是修改密碼功能\n");

char oldpassword[7];

char newpassword[7];

char newpassword1[7];

int i;

for(i=0;i3;i++){

printf("\n\t\t\t 請(qǐng)輸入舊密碼:\n");

inputpassword(oldpassword);

if(strcmp(oldpassword,one.password)==0){

printf("\n\t\t\t 輸入成功!\n");

break;

}else{

printf("\n\t\t\t 密碼輸入有誤,請(qǐng)重新輸入!\n");

}

}

if(i3){

while(1){

printf("\n\t\t\t 請(qǐng)輸入您的新密碼:\n");

inputpassword(newpassword);

printf("\n\t\t\t 請(qǐng)輸入您的確認(rèn)密碼:\n ");

inputpassword(newpassword1);

if(strcmp(newpassword,newpassword1)==0){

strcpy(one.password,newpassword);

fseek(fp,-sizeof(one),1);

fwrite(one,sizeof(one),1,fp);

printf("\n\t\t\t 密碼修改成功!");

break;

}else{

printf("\n\t\t\t 兩次密碼輸入不一致!");

}

}

}else{

printf("\n\t\t\t 密碼輸入錯(cuò)誤!");

}

}

int zhuxiaozhanghao()

{

system("cls");

int zhuxiaoxitong;

char sf;

printf("你要注銷的賬號(hào)是%d",one.account);

printf("你是否要對(duì)此賬號(hào)進(jìn)行注銷?\n\n\t\t請(qǐng)您選擇:注銷(Y)or不注銷(N):");

fflush(stdin);

scanf("%c",sf);

if(sf=='y'||sf=='Y')

{

printf("正在為您注銷!\n",one.account);

zhuxiaoxitong=1;

}else{

printf("不注銷系統(tǒng)!\n",one.account);

}

return zhuxiaoxitong;

}

void service()

{

while(1){

system("cls");

printf("\n\n\n\t\t\t\t\t\t現(xiàn)在是服務(wù)系統(tǒng),本系統(tǒng)有以下服務(wù)");

printf("\n\t\t\t\t\t\t[a] 查詢余額\n");

printf("\n\t\t\t\t\t\t[b] 存款服務(wù)\n");

printf("\n\t\t\t\t\t\t[c] 轉(zhuǎn)賬服務(wù)\n");

printf("\n\t\t\t\t\t\t[d] 取款服務(wù)\n");

printf("\n\t\t\t\t\t\t[e] 修改密碼\n");

printf("\n\t\t\t\t\t\t[f] 注銷 \n");

printf("\n\t\t\t\t\t\t[g] 退出系統(tǒng)\n");

char e;

printf("\n\t\t\t\t\t\t您要選擇的服務(wù)是:");

fflush(stdin);

scanf("%c",e);

switch(e)

{ case'A':

case'a': searchmoney() ;break;

case'B':

case'b': savemoney() ;break;

case'C':

case'c': transfermoney() ;break;

case'D':

case'd': withdrawalmoney() ;break;

case'E':

case'e': xiugai() ;break;

case'F':

case'f': {int zhuxiaoxitong=zhuxiaozhanghao();{if(zhuxiaoxitong==1) return;}break;}

case'G':

case'g': quite();break;

}

printf("\n\n\n\t\t\t\t按任意鍵繼續(xù)......\n");

getch();

}

}

void login()

{

fp=fopen("atm.txt","rb+");

if(fp==NULL)

{

printf("\n\n\n\t\t\t\t文件打開(kāi)失敗!");

return;

}

system("cls");

printf("\n\t\t\t\t\t\t現(xiàn)在執(zhí)行的是登錄函數(shù)的使用\n");

int zhanghao;

printf("\n\t\t\t\t\t\t請(qǐng)輸入賬號(hào):");

scanf("%d",zhanghao);

int flag=0;

while(fread(one,sizeof(one),1,fp)==1)

{

if(zhanghao==one.account){

flag=1;

break;

}

}

char password2[7];

if(flag==1){

int h;

for(h=0;h3;h++){

printf("\n\t\t\t\t\t\t請(qǐng)輸入密碼:");

fflush(stdin);

inputpassword(password2);

if(strcmp(password2,one.password)==0)

{

printf("\n\t\t\t\t\t\t登陸成功!");

service();

break;

}else{

printf("密碼不正確!");

}

}

if(h==3){

printf("\n\t\t\t您的密碼三次輸入有誤,返回");

}

}else{

printf("無(wú)此賬號(hào)!");

}

fclose(fp);

}

void quite()

{

system("cls");

printf("\t\t\t現(xiàn)在執(zhí)行的是退出函數(shù)的使用\n");

exit(0);

}

怎樣用c語(yǔ)言編寫(xiě)ATM系統(tǒng)?

#includestdio.h

#includestring.h

void print_welcome();

int main()

{

print_welcome();

char c[11]="1234567890",d[7]="123456";

char a[20],b[20];

char p,q;

int h=0,i=0,j=0,k,l=0;

do

{

printf("請(qǐng)輸入賬號(hào):\n");

gets(a);

printf("請(qǐng)輸入密碼:\n");

gets(b);

if(strcmp(c,a)==0strcmp(d,b)==0)

{

printf("賬號(hào)正確 歡迎使用\n");

h++;

}

else

printf("賬號(hào)或密碼錯(cuò)誤請(qǐng)重新輸入\n");

}while(h!=1);

do

{

print_welcome();

retrn:

printf("請(qǐng)選擇對(duì)應(yīng)的字母\n");

printf(" a存款業(yè)務(wù) \n");

printf(" b余額查詢\n");

printf(" c資金轉(zhuǎn)賬\n");

printf(" d取款業(yè)務(wù)\n");

printf(" e退卡\n");

printf("請(qǐng)選擇您要辦理的業(yè)務(wù)\n");

scanf("%c",p);

getchar();

switch(p)

{

case'a':printf(" 存款業(yè)務(wù)\n");

printf("**本服務(wù)暫停 請(qǐng)重新選擇**\n");

break;

case'b':

printf(" 余額查詢\n");

printf("**您的余額為 ¥9999999\n請(qǐng)重新選擇**\n");

break;

case'c':

printf(" 資金轉(zhuǎn)賬\n");

printf("**您的銀行卡不支持該業(yè)務(wù) 請(qǐng)重新選擇**\n");

break;

case'd':

printf(" 取款業(yè)務(wù)\n");

do

{

printf("請(qǐng)選擇您要取款的金額\n**請(qǐng)輸入序號(hào)\n**請(qǐng)您注意每位用戶每天只能去20000 每次最多取2500\n");

printf(" r 100\n");

printf(" s 200\n");

printf(" t 500\n");

printf(" u 1000\n");

printf(" v 2000\n");

printf(" w 其他\n");

printf(" x 返回\n");

printf("請(qǐng)選擇要取的金額\n");

scanf("%c",q);

getchar();

switch(q)

{

case'r':printf("**取款成功 金額為100元**");goto retrn;break;

case's':printf("**取款成功 金額為200元**");goto retrn;break;

case't':printf("**取款成功 金額為500元**");goto retrn;break;

case'u':printf("**取款成功 金額為1000元**");goto retrn;break;

case'v':printf("**取款成功 金額為2000元**");goto retrn;break;

case'w':printf("**請(qǐng)輸入你想取出的金額**\n**并保證是100的倍數(shù)\n");

while(l!=1)

{

scanf("%d",k);

getchar();

if(k%100==0k=0k=2500)

{

printf("您取出的金額%d元\n",k);

l++;

goto retrn;

}

else

{

printf("您輸入的面額有誤請(qǐng)重新輸入\n");

printf("請(qǐng)您保證為100的倍數(shù)\n");

}

}

break;

case'x':goto retrn;break;

default:printf("**操作有誤請(qǐng)從新輸入**");

j++;

}

}while(j!=1);

break;

case'e':

printf("**歡迎您的使用 請(qǐng)勿忘取卡**\n");

i++;

break;

default:printf("**操作有誤請(qǐng)從新輸入**\n");

}

}while(i!=1);

print_welcome();

return 0;

}

void print_welcome()

{

printf(" **歡迎使用**\n");

}

急求一個(gè)C語(yǔ)言編寫(xiě)的銀行存取款管理設(shè)計(jì)的程序。

#includeiostream#includecstringusing namespace std;class count{public:friend class ATM;count (char Name[],char Num[],floatMoney,char Password[]); //初始化protected:char * get_name(); //返回姓名char * get_num(); //返回卡號(hào)char * get_password(); //返回密碼float get_money(); //返回金額void set_password(char pwd[]); //設(shè)置密碼void set_money(float m); //取錢(qián)private:char password[6]; //用戶密碼char name[20]; //用戶姓名char num[20];float money;};class ATM{public:ATM(count cn):ctm(cn){}void welcome(); //登陸界面bool check_password(char p[],char pwd[]); //核對(duì)密碼void change_password(); //修改密碼void get_money(); //取錢(qián)void get_information(); //查詢信息void exit_ATM(); //退出ATMvoid show_function(); //功能界面void push_card(); //吞卡private:int times; //記錄輸入密碼的次數(shù)count ctm;};//構(gòu)造ATM的函數(shù)void ATM::welcome() //構(gòu)造welcome{times=0;cout"歡迎使用ATM模擬自動(dòng)取款機(jī)"endl;cout"-------------------------"endl;cout"請(qǐng)選擇:\n1.新開(kāi)帳戶\t2.客戶服務(wù)\t3.退出系統(tǒng)"endl; //輸出主菜單char pwd[7],num[20]; //6位密碼19位卡號(hào)int i=0;do{cout"請(qǐng)輸入卡號(hào)";cinnum;cout"請(qǐng)輸入密碼:";cinpwd;if(!check_password(num,pwd)){cout"你輸入的密碼有錯(cuò)誤,請(qǐng)重新輸入"endl;times++;}else{show_function();}}while(times3);push_card();}bool A.....

用C語(yǔ)言寫(xiě)ATM的程序代碼要求用循環(huán)語(yǔ)句

#includestdio.h

int chaxun(int a3)

{

int b;

b=a3;

printf("你的余額為:%d\n",b) ;

}

int qukuan(int a3)

{

int a,b;

printf("請(qǐng)輸入您要提取的現(xiàn)金:\n");

scanf("%d",a);

b=a3-a;

if(b0)

printf("對(duì)不起 ,你的余額不足\n");

else

{

printf("請(qǐng)收好您的%d元現(xiàn)金\n",a);

a3=a3-a;

}

return (a3);

}

int gaini(int a2)

{

int a,b,c=1,d,e=1;

while(e)

{

printf("請(qǐng)輸入你的舊密碼:\n");

scanf("%d",d);

if(d==a2)

e=0;

else

{

e=1;

printf("你輸入的密碼錯(cuò)誤,請(qǐng)重新輸入:\n");

}

}

while(c)

{

printf("請(qǐng)輸入您的六位數(shù)新密碼\n");

scanf("%d",a2);

printf("請(qǐng)確認(rèn)您的六位數(shù)新密碼\n");

scanf("%d",b);

if(a2==b)

{

if(b100000b999999b/(b/100000)!=111111)

{

c=0;

printf("密碼修改成功\n");

}

else

{

printf("您輸入的密碼不符合要求,請(qǐng)從新輸入\n");

c=1;

}

}

else

{

c=1;

printf("您兩次輸入的密碼不一致,請(qǐng)重新輸入:\n");

}

}

return a2;

}

int quka()

{

printf("\n 夢(mèng)若保保提醒您\n");

printf("請(qǐng)收好您的卡片,謝謝,再見(jiàn)\n\n");

}

int cunkuan(int a3)

{

int i,j,k;

printf("請(qǐng)輸入你要存的金額\n");

scanf("%d",k);

if(k0)

{

printf("對(duì)不起,沒(méi)有負(fù)存款\n");

}

else

{

printf("\n您好,您已經(jīng)存進(jìn)去了%d元\n",k);

a3=a3+k;

}

return a3;

}

main()

{

int i,j,b=1,c,k,l,m,n;

int a1=123456,a2=123456,a3=1000;

printf("歡迎使用自動(dòng)柜員機(jī):\n\n");

while(b==1)

{

printf("請(qǐng)輸入您的賬號(hào):\n");

scanf("%d",k);

printf("請(qǐng)輸入您的密碼:\n");

scanf("%d",l);

if(k==a1l==a2)

{

b=0;

printf("您的賬戶余額為:%d\n",a3);

}

else

{

b=1;

printf("對(duì)不起,您輸入的賬號(hào)或者密碼有誤,請(qǐng)重新輸入:\n");

}

}

do

{

printf("\n請(qǐng)選擇您要的服務(wù)項(xiàng)目:\n");

printf("1.查詢余額\n");

printf("2.取款\n");

printf("3.修改密碼\n");

printf("4.取卡\n");

printf("5.存款\n");

scanf("%d",c);

switch(c)

{

case 1:

chaxun(a3);

break;

case 2:

a3=qukuan(a3);

break;

case 3:

a2=gaini(a2);

break;

case 4:

quka();

break;

case 5:

a3=cunkuan(a3);

break;

}

}while(c!=4);

}


新聞標(biāo)題:C語(yǔ)言的函數(shù)設(shè)計(jì)ATM C語(yǔ)言函數(shù)設(shè)計(jì)
分享URL:http://weahome.cn/article/dodjeio.html

其他資訊

在線咨詢

微信咨詢

電話咨詢

028-86922220(工作日)

18980820575(7×24)

提交需求

返回頂部