java的第一个小项目

                                            **银行取款案例**
  1. package day1

  2. import java.util.Scanner; // 导入外包中的类,类的地址

  3. public class 条件语句 {

  4. public static void main(String[] args) {

  5. Scanner s = new Scanner(system.in);

  6.                             // 创建一个Scanner类的对象
                               //  Scanner s创建一个Scanner类型的变s
                              //   new Scanner(System.in)创建对象
    
  7.      int  money = 500;
    
  8.      int  count = 0;
    
  9.       while (true) {
    
  10.           if  ( count == 3 ) {
    
  11.                System.out.println("密码已经输错三次,卡已锁定");
    
  12.        break;
    
  13.        }
    
  14.     System.out.println("请输入卡号");
    
  15.     int card = s.nextInt();
    
  16.     System.out.println("请输入密码");
    
  17. int password = s.nextInt();

  18.     if(  card==666 && password==111  ) {
    
  19.     System.out.println("请输入取款金额");
    
  20.     int m = s.nextInt();
    
  21.  	      if(m<money){ 
    
  22.          System.out.println("取款成功");
    
  23.           } else {
    
  24.      System.out.println("余额不足");
    
  25.     }
    
  26.     } else {
    
  27.           System.out.println("卡号或密码错误");
    
  28.           count++;
    
  29.     }
    
  30.     }
    
  31. }

  32. }

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值