Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

java please Problem Statement For program 2 you will simulate playing the lottery. You will begin by simulating drawing 3 numbers by generating three random

java please
image text in transcribed
image text in transcribed
image text in transcribed
Problem Statement For program 2 you will simulate playing the lottery. You will begin by simulating drawing 3 numbers by generating three random numbers. Then, you will prompt the user to "Play the lotto" and ask for their three numbers. Determine if they are a winner: 1. If they guess all 3 numbers correctly, they win $1,000 2. If they guess at least one number correctly (but not all 3), they win $100 3. If they didn't guess any numbers correctly, they lose Input Data - 3 numbers: - one between 1 and 10 - a second between 11 and 20 - a third between 21 and 30 Output Data - The 3 lottery numbers - Whether or not they won, and, if so, the dollar amount of their winnings. Getting Started Include header comments formatted as shown below (you may want to copy and paste the header from a previous lab assignment and edit it, do not forget to include the program description). Algorithm 1. Generate three random numbers: one between 1 and 10 , a second between 11 and 20 , and a third between 21 and 30 . Use meaningful yariable names such as iotteru1, lotterv2 and lotterk 3 . Algorithm 1. Generate three random numbers; one between 1 and 10,8 second between 11 and 20 , and a third between 21 and 30 . Use meaningful yariable names such as bottery1. kottery2, and lottery 3. NOTE: To test your program you will want to print out the three lottery numbers so you know the numbers generated and can test all three possibilities (guessing all 3 numbers, guessing 1 or 2 numbers, guessing no numbers). 2. Prompt (ask) the user for their three lottery numbers: one between 1 and 10, a second between 11 and 20 , and a third between 21 and 30. Cont'd on next page III 3. Determine if the user's lottery numbers are within range - the first should be between 1 and 10 , the second between 11 and 20 , and the third between 21 and 30 (you must use just ONE If-statement with a compound condition to check this). If they are all within their ranges, continue onto step 4. If not, output their numbers were invalid and do not continue. 4. Determine if the user is winner. You must use a compound condition in the if-statements: a. If all three numbers are correct (i.e., their first number is the same as the first lottery number you generated, their second the same as the second lottery number, and their third the same as the third lottery number), they win $1,000. b. If one or two of their numbers are correct, but not all three, they win $100. c. If none of their numbers are correct, they do not win anything. 5. Output the result (See sample output below) a. The 3 lottery numbers b. Whether or not the user is a winner, if a winner, the dollar amount of their winnings 5. Output the result (See sample output below) a. The 3 lottery numbers b. Whether or not the user is a winner, if a winner, the dollar amount of their winnings 6. Before each significant step, provide a comment explaining the step (do not comment every line of code). Test Plan In order to receive credit, you must show the cases below. Also, submit your program on Blackboard under Lab Assignments (Click on the words Program 2, scroll down to Browse My Computer, navigate and click the LotteryYourLastName.java file, scroll down, and click Submit). Your electronic submission of the program file will represent your endorsement of the Honor Code Statement. 1. The case when all three of the user's numbers match the lottery number - win $1,000 2. The case when only the second number matches the second lottery number - win $100 3. The case when one of the three numbers is out of range

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

Expert Performance Indexing In SQL Server

Authors: Jason Strate, Grant Fritchey

2nd Edition

1484211189, 9781484211182

More Books

Students also viewed these Databases questions

Question

=+90 percent of all oil refineries) into several smaller companies

Answered: 1 week ago