Question: Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Allow the user

Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Allow the user to guess three numbers. Compare each of the users guesses to the three random numbers and display a message that includes the users guess, the randomly determined three-digit number, and the amount of money the user has won as follows: Matching Numbers Any one matching Two matching Three matching, not in order Three matching in exact order No matches award ($) 10 100 1,000 1,000,000 0 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 guessesjust one. Save the file as Lottery.java.

Here is what our professor provided.

import javax.swing.*; public class Lottery { public static void main (String args[]) { final int HIGHEST_WIN = 1000000; final int SECOND_BEST_WIN = 1000; final int THIRD_BEST_WIN = 100; final int LOW_WIN = 10; String entry; int number1; int number2; int number3; int userGuess; int ran1, ran2, ran3; int random; int matches = 0; int winnings = 0; ran1 = (int)Math.floor(Math.random()*10); ran2 = (int)Math.floor(Math.random()*10); ran3 = (int)Math.floor(Math.random()*10); random = ran1 * 100 + ran2 * 10 + ran3; entry = JOptionPane.showInputDialog(null, "Enter first digit"); number1 = Integer.parseInt(entry); entry = JOptionPane.showInputDialog(null, "Enter second digit"); number2 = Integer.parseInt(entry); entry = JOptionPane.showInputDialog(null, "Enter last digit"); number3 = Integer.parseInt(entry);

// Enter your sonditional statements here // // //**************** JOptionPane.showMessageDialog(null, "You guessed " + number1 + number2 + number3 + " Winning number was " + random + " You have won $" + winnings + "!"); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!