彩票
import java.util.Scanner; public class Lottery { public static void main(String[] args){ int lottery1,lottery2,guess1,guess2; int lottery = (int)(Math.random()*100); System.out.println("请输入彩票数字!(0-99的整数!)"); Scanner input = new Scanner(System.in); int guess = input.nextInt(); lottery1 = lottery % 10; lottery2 = lottery / 10; guess1 = guess % 10; guess2 = guess / 10; System.out.println(lottery); if (lottery == guess){ System.out.println("恭喜你中了一等奖!奖金为10000美金!"); } else if (lottery1 == guess2 && lottery2 == guess1){ System.out.println("恭喜你中了二等奖!奖金为3000美金!"); } else if (lottery1 == guess1 || lottery1 == guess2 || lottery2 == guess1 || lottery2 == guess2){ System.out.println("恭喜你中了三等奖!奖金为1000美金!"); } else{ System.out.println("很遗憾,您没有中奖!(*+﹏+*)~ "); } } }
随机产生一个两位数的彩票,提示用户输入一个两位数的整数。