zoukankan      html  css  js  c++  java
  • 问题一百三十五:银行ATM

    /**************************************************************
    ****Auther:liuyongshui
    *****About:This is the BANK ATM applicantion
    ******Date:20130511
    **************************************************************/
    
    #include <stdio.h>
    #include <string.h>
    #include <conio.h>
    
    #define interst_rate 0.035
    
    float sum_money=654321.0;
    //annual interest
    float interest_rate=0.035;
    
    void Star(void);
    void Choice(void);
    int  Check_password(void);
    void Deposit_money(viod);
    void Withdraw_money(void);
    void Transfer_money(void);
    void Count_rate(void);
    
    int main()
    {     
    	  int num;
    	  int mark;
          int sign;
          
    	  sign=1;
    	  Star();
          printf("\t\tWELCOME TO LEDUODUO BANK\t\t\t\t\n");
          
    	  mark=Check_password();
    	  if(mark)
    	  {
    		  printf("LOGIN SUCCEDFUL!\n");
    	  }
    	  else 
    	  {
    	      printf("SORRY,LOGIN FILED!\n");
    		  sign=0;
    	  }
         
          while(1)
    	  {
              if(sign==0)
    		  {   
    			   printf("\nService is you choose to quit!\n");
    		       break;
    		  }
               
    		  Choice();
              printf("\nplease select a service NUMBER you want:");
    		  scanf("%d", &num);
    	      switch(num)
    		   {
    			   case 1:  Deposit_money();   
    				        break;
    			   case 2:  Withdraw_money();
    				        break;
    			   case 3:  Transfer_money();
    				        break;
    			   case 4:  Count_rate();
    				        break;
    			   case 0:  sign=0;
    				        break;
    		   }
    	  }
    
    	  printf("Thank your for you use!\n");
          Star();
          return 0;
    }
    
    // Function define
    
    void Star(void)
    {
         int i;
    	 
    	 for(i=0; i<60; i++)
    	 {
    	     printf("*");
    	 }
    
    	 printf("\n");
    }
    
    void Choice(void)
    {
    	printf("\nplease select a service NUMBER you want.\n");
        printf("\n\t\t 1:deposit money\n\t\t 2:withdraw money\n\t\t 3:transfer money\n\t\t 4:count money\n\t\t 0:quit\n\n");
    }
    
    int Check_password(void)
    {
        int  i;
    	int  j;
    	int  k;
    	int  flag;
    	char ch;
    	char code[10]={'\0'};
    	char password[10]={"123456"};
        
        // You can input password three times 
    	for(i=0; i<3; i++)      
    	{
    		 printf("Please enter the 6 digit code:");
    		 //Make code[k] every time starting from 0
    	     k=0;  
    		 //Tage  code is accurate
    		 flag=1;   
    
    		 while((ch=getch()) && ch!=13 && k<6)
    		 {
    		     putchar('*');
    
    			 code[k++]=ch;
    		 }
    
    		 //Code is accurate
    		 for(j=0; j<6; j++)
    		 {
    		     if(password[j] != code[j])
    			 {
    				 // code is wrong!
    			     flag=0;         
    			 }
    		 }
    
    		 if(flag)
    		 {
    		      printf("\nYou code is accurate!\n");
    			  return 1;
    		 }
    		 else 
    		 {     
    			 if(i<2)
    			 {
    				 printf("\nYou enter wrong password! Pleas enter the password again!\n");
    			 }
    			 else 
    			 {
    			     printf("\nYou input three wrong password three times,your account has been locked!\n");
    			 }
    		 }
         
    	}
    
    	return 0;
    }
    void Deposit_money(void)
    {
        float money;
        
    	printf("\nService is you choose to deposit money.");
    	printf("\nPlease input you want to deposit money:");
    	scanf("%f", &money);
        
    	sum_money+= money;
    
        printf("\nThey have %f yuan on your account.\n", sum_money);
    
    	Star();
    }
    
    void Withdraw_money(void)
    {
        float money;
        
    	printf("\nService is you choose to withdraw money.");
    	printf("\nPlease input you want to withdraw money:");
    	scanf("%f", &money);
    
    	sum_money-=money;
    
        printf("\nYou want take money is %f yuan\n", money);
    	printf("\nThey have %f yuan on your account.\n", sum_money);
    
    	Star();
    }
    
    void Transfer_money(void)
    {
    	float money;
     
    	printf("\nService is you choose to transfer money.");
    	printf("\nPlease input you want to tansfer money:");
    	scanf("%f", &money);
    
    	sum_money-=money;
    
    	printf("\nYou want transfer money %f yuan", money);
    	printf("\nThey have %f yuan on your account.\n", sum_money);
    
    	Star();
    }
    
    void Count_rate(void)
    {   
    	int    i;
        int    year;
        float  interest;
    	
    	printf("\nService is you choose to count rate.");
    	printf("\nPlease input the number of year you want deposit:");
    	scanf("%d", &year);
    
    	for(i=1; i<=year; i++)
    	{   
    		interest=sum_money*interest_rate;
    	    sum_money+=interest;
    		printf("%2d year,you will have interest:%f yuan,you will have sum_money:%f yuan.\n", i, interest, sum_money);
    	}
    
    	Star();
    }

     局部图:


  • 相关阅读:
    谁能撼动C语言的霸主地位?是Go?是Rust?还是...
    从入职到快速晋升,程序员能够从底层逆袭,究竟是什么原因?
    我敢说,这8个Linux基础命令,学了绝不吃亏!(强烈推荐)
    想从程序员到百万高管,你一定要避开这3个坑!(年轻人必读)
    注意!在Linux中删除特殊名称文件有这6种方式!(建议收藏)
    事实证明!这10个Linux系统操作指令,简直 “不讲武德” ,请大家耗子尾汁!
    最适合单片机编程的高级语言,除了C语言,别无选择!
    “Help”!如何学习C和C++才不茫然,才不是乱学?
    C语言丨不要阅读此文,除非你已掌握二叉树的这些操作
    团队编程项目作业2-团队编程项目开发环境搭建过程
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/3073171.html
Copyright © 2011-2022 走看看