简单提款机取款-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 }

 

转载于:https://www.cnblogs.com/yinxiangjinan/p/11109681.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值