简单提款机取款-java
2020-12-13 04:25
标签:java pack ack 三次 out 次数 int() pre 完成 简单提款机取款-java 标签:java pack ack 三次 out 次数 int() pre 完成 原文地址:https://www.cnblogs.com/yinxiangjinan/p/11109681.html 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 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 ) {
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 }