• ATM模拟取款


    package zhuoxiang;
    import java.util.Scanner;
    public class ATMqukuan {
        public static void main(String[] args) {
            Scanner input=new Scanner(System.in);
            for(int i=1;;i++){
                if(i%4!=0){
                    System.out.print("请输入密码(数字):");
                    int password=input.nextInt();
                    if(password==111111){
                        System.out.println("请输入金额");
                        int amount=input.nextInt();
                        while(true){
                            if(amount<=1000&&amount>=0&&amount%100==0){//判断金额为整百的倍数且不超过1000
                                System.out.println("您取了"+amount);
                                System.out.println("交易完成,请取卡!");
                            return;//跳出函数
                            }else{
                                System.out.println("您输入的金额错误,请重新输入:");
                                amount=input.nextInt();
                            }
                        }
                    }else{
                        System.out.println("密码错误,您还剩余"+(3-i)+"次机会");}
                }else{
                    System.out.println("卡已吞,请到人工台进行处理");
                    break;//跳出循环体
                }
            }
            input.close();
        }
    }




  • 相关阅读:
    拷贝构造函数与赋值函数的区别
    C++模板(一)
    拷贝构造函数
    memcpy函数
    malloc calloc 和 realloc
    extern关键字
    C中不安全函数
    缓冲区溢出问题
    C++引用
    背包问题专栏(01,完全,多重)
  • 原文地址:https://www.cnblogs.com/infernofranz/p/5715803.html
Copyright © 2020-2023  润新知