zoukankan      html  css  js  c++  java
  • *

     1 package test;
     2 
     3 import java.util.Scanner;
     4 
     5 public class Lottery {
     6 
     7     public static void main(String[] args) {
     8         // TODO Auto-generated method stub
     9 
    10         int lottery = (int)(Math.random()*100);
    11         
    12         Scanner input = new Scanner(System.in);
    13         System.out.print("Enter your lottery pick (two digits):");
    14         int guess = input.nextInt();
    15         
    16         int lotteryDigit1 = lottery/10;
    17         int lotteryDigit2 = lottery%10;
    18         
    19         int guessDigit1 = guess/10;
    20         int guessDigit2 = guess%10;
    21         
    22         System.out.println("The lottery number is " + lottery);
    23         
    24         if(guess==lottery)
    25             System.out.println("Exact match : youwin $10,000");
    26         else if   (guessDigit2 == lotteryDigit1
    27                 && guessDigit1 == lotteryDigit2)
    28             System.out.println("Match all digits:you win $3.000");
    29         else if      (guessDigit1 == lotteryDigit1
    30                 || guessDigit1 == lotteryDigit2
    31                 || guessDigit2 == lotteryDigit1
    32                 || guessDigit2 == lotteryDigit2)
    33             System.out.println("Match one digit: you win $1.000");
    34         else
    35             System.out.println("Sorry,no match");
    36             
    37     }
    38 
    39 }
  • 相关阅读:
    C语言第三天,《常量指针和指针常量》
    树莓派系统烧入总结
    c 语言第一天
    7. Vue
    6. Vue
    5. Vue
    4. Vue
    3. Vue
    1. Vue
    2. Vue
  • 原文地址:https://www.cnblogs.com/King-boy/p/10498350.html
Copyright © 2011-2022 走看看