zoukankan      html  css  js  c++  java
  • 初学Java *

     1 import java.util.Scanner;
     2 
     3 public class Lottery {
     4   public static void main(String[] agrs) {
     5     int lottery = (int)(Math.random() * 100);
     6     
     7     Scanner input = new Scanner(System.in);
     8     System.out.print("Enter your lottery pick (two digits): ");
     9     int guess = input.nextInt();
    10     
    11     int lotteryDigit1 = lottery / 10;
    12     int lotteryDigit2 = lottery % 10;
    13     
    14     int guessDigit1 = guess / 10;
    15     int guessDigit2 = guess % 10;
    16     
    17     System.out.println("The lottery number is " + lottery);
    18     
    19     if (guess == lottery)
    20         System.out.println("exact match: you win $10000");
    21     else if (guessDigit2 == lotteryDigit1
    22             && guessDigit1 == lotteryDigit2)
    23         System.out.println("Math all digits: you win $3000");
    24     else if (guessDigit1 == lotteryDigit1
    25             || guessDigit1 == lotteryDigit2
    26             || guessDigit2 == lotteryDigit1
    27             || guessDigit2 == lotteryDigit2)
    28         System.out.println("Match one digit: you win $1000");
    29     else 
    30         System.out.println("Sorry, no macth");
    31   }
    32 }
  • 相关阅读:
    Emacs 安装 jedi
    PHP+ MongoDB
    Debian 7 安装 Emacs 24.3
    在Code first中使用数据库里的视图
    Emacs安装auto-complete
    Debian 7.4 中配置PHP环境
    ASP.NET MVC 下载列表
    JDicom使用指南
    Windows常用的DOS命令
    Entity Framework问题总结
  • 原文地址:https://www.cnblogs.com/leo2li/p/9641287.html
Copyright © 2011-2022 走看看