In JAVA WITHOUT ARRAYS , create a lottery game application. Generate three rando
ID: 3712022 • Letter: I
Question
In JAVA WITHOUT ARRAYS, create a lottery game application. Generate three random numbers, each between 0 and 9. Allow the user to guess three numbers. Compare each of the user's guess to the three random numbers and display a message that includes the user's guess, the randomly determined three-digit number, and the amount of money the user has won as follows:
make certain that your application accommodates repeating digits. For example, if a user guesses 1,2, and 3, and the randomly generated digits are 1,1, and 1, do not give the user credit for three correct guesses - just one. Save the file as Lottery.java.
matching numbers award ($) any one matching 10 two matching 100 three matching not in order 1,000 three matching in exact order 1,000,000 no matches 0Explanation / Answer
import java.util.Random;
import java.util.Scanner;
public class Driver {
public static void main(String[] args){
Random r = new Random();
int a = r.nextInt(10);
int b = r.nextInt(10);
int c = r.nextInt(10);
System.out.println("Enter the three numbers: ");
Scanner in = new Scanner(System.in);
int first = in.nextInt();
int second = in.nextInt();
int third = in.nextInt();
System.out.println(a);
System.out.println(b);
System.out.println(c);
if((first == a && second != b && third != c) && (first != a && second == b && third != c) && (first != a && second != b && third == c))
System.out.println("Award is 10");
else if((first == a && second == b && third != c) && (first == a && second != b && third == c) && (first != a && second == b && third == c))
System.out.println("Award is 100");
else if(first == a && second == b && third == c)
System.out.println("Award is 1,000,000");
else if (first != a && second != b && third != c)
System.out.println("Award is 0");
else
System.out.println("Award is 1,000");
}
}
**Comment for any further queries.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.