简单提款机取款-java
作者:互联网
1 package org.lxh.Demo; 2 3 import java.util.Scanner; 4 5 public class JavaDemo01{ 6 public static void main(String[] args) { 7 Scanner scan = new Scanner(System.in); 8 String password = "111111"; 9 int passwordCount = 0; //密码输入次数 10 boolean passwordPass = false; //密码在三次以内通过 11 while(passwordCount <=3 && !passwordPass) { 12 System.out.println("请输入密码:"); 13 if(!scan.next().equals("111111")) { 14 passwordCount++; 15 continue; 16 } 17 passwordPass = true; 18 System.out.println("请输入取款金额:"); 19 int money = scan.nextInt(); 20 while(money > 0) { 21 if(money <= 1000 && money%100 == 0) { 22 System.out.println("您取了"+ money+ "元"); 23 System.out.println("交易完成,请取卡"); 24 break; 25 }else { 26 System.out.println("您输入的金额不合法,请重新输入:"); 27 money = scan.nextInt(); 28 continue; 29 } 30 } 31 } 32 if(!passwordPass) { 33 System.out.println("密码输入错误,请取卡!"); 34 } 35 } 36 }
标签:java,String,public,密码,提款机,passwordCount,取款,Scanner 来源: https://www.cnblogs.com/yinxiangjinan/p/11109681.html