Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Reliability Engineering Designing And Operating Resilient Database Systems

Authors: Laine Campbell, Charity Majors

1st Edition

978-1491925942

More Books

Students also viewed these Databases questions

Question

=+ Where would most corporations like the balance to fall?

Answered: 1 week ago