A program of ATM machines written in C language

Source: Internet
Author: User
Tags strcmp

Learning C language for one weeks, the teacher assigned to work, using C to write an ATM simulation program, customer interface has, withdrawals, 2 deposits, 3 transfers, 4 exit.

And after the input error is required, there are three chances to re-lose, define the input password hellowold, with Switch branch.

#include <stdio.h>#include<string.h>#defineKey "Hellowold"//Define Password#defineZhanghu "123456789"#defineLine "==================\n"intNum//Select TypeChararr[ -];//Defining ArraysCharpassword[ -];//Defining ArraysintMoney//Withdrawal AmountintI=0;intMain () {printf (line); printf ("\t1 withdrawals \ n"); printf ("\t2 deposit \ n"); printf ("\t3 transfer \ n"); printf ("\t4 exit \ n");        printf (line); printf ("Please select the type of operation: \ n"); scanf ("%d",&num); Switch(num) { Case 1:            {    Do{printf ("Please enter your password: \ n"); scanf ("%s",&password); if(strcmp (key,password) = =0) {printf ("Please enter the withdrawal amount: \ n"); scanf ("%d",&Money ); printf ("Please take your%d grandpa's hair.", Money);  Break; }                    Else{printf ("Password input Error"); } I++; }                    while((strcmp (key,password)! =0) &&i<=2); }        } 

Second step deposit, define Account

#include <stdio.h>#include<string.h>#defineKey "Hellowold"//Define Password#defineZhanghu "#defineOther "ni de mao ye Ye"#defineLine "==================\n"intNum//Select TypeChararr[ -];//Defining ArraysCharpassword[ -];//Defining ArraysCharothers[ -];intMoney//Withdrawal Amountintnum2;//Deposit AmountintI=0;intMain () {printf (line); printf ("\t1 withdrawals \ n"); printf ("\t2 deposit \ n"); printf ("\t3 transfer \ n"); printf ("\t4 exit \ n");        printf (line); printf ("Please select the type of operation: \ n"); scanf ("%d",&num); Switch(num) { Case 1:            {    Do{printf ("Please enter your password: \ n"); scanf ("%s",&password); if(strcmp (key,password) = =0) {printf ("Please enter the withdrawal amount: \ n"); scanf ("%d",&Money ); printf ("Please take your%d grandpa's hair.", Money);  Break; }                    Else{printf ("Password input Error"); } I++; }                    while((strcmp (key,password)! =0) &&i<=2);  Break; }        

Today first change to here, the homework is more, typesetting is not very good-looking, it will look at it.


A program of ATM machines written in C language

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.