Multi branch practice lottery game, randomly generate two one digit random numbers, and prompt the user to enter the guessed number

The code is as follows:

/*Multi branch practice lottery game, randomly generate two one digit random numbers, and prompt the user to enter the guessed number. If it exactly matches the bonus of 10000, only match the number, no matching order bonus of 3000, and only match one number Bonus of 1000 cases: if the generated random number is 18, if the user enters 18, the bonus of 10000; If the user enters 81 bonus 3000; If the user enters 16 bonus 1000 * / import Java util. Scanner; Class demo13 {public static void main (string [] args) {/ / randomly generate two one digit numbers int a = (int) (math. Random() * 10); int b = (int) (math. Random() * 10); system.out.println (a + "," + b); / / prompt the user to enter the Guessing Number scanner SC = new scanner (system. In); system.out.println ("please enter the Guessing Number:"); int x = sc.nextint(); int y = sc.nextint()) ; // Judge if (a = = x & & B = = y) system out. Println ("winning 10000 yuan"); else if(a==y&&b==x) System. out. Println ("winning 3000 yuan"); else if(a==x||a==y||b==x||b==y) System. out. Println ("winning 1000 yuan"); else System. out. Println ("if you don't win the prize, please continue to play");}}

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>