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 }
  • 相关阅读:
    Swift
    Swift
    第二章_session管理
    HDU-1387-Team Queue
    Install Orace 11g on Solaris 10 Sparc 64 bit
    Linux 多学习过程
    dispatch_once认识分析
    关于包围神经猫的想法实现
    嵌入在网站上Flash播放机(2)
    初学者应学会如何加快seo
  • 原文地址:https://www.cnblogs.com/leo2li/p/9641287.html
Copyright © 2011-2022 走看看