Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using java and without using loops 5. Variation of the Lottery Problem: Write a Java program that first generates a random 3-digit positive integer; then

image text in transcribed
using java and without using loops
5. Variation of the Lottery Problem: Write a Java program that first generates a random 3-digit positive integer; then prompts the user to enter a 3-digit integer him-/herself; then compares the random integer with the user-entered integer and does the following: - If the numbers exactly match: "Congratulations! You won the lottery $10,000 prize!"; - If any 2 out of 3 digits match: "Congrats - you won the second prize of $500!"; - If exactly one digit matches: You won $10"; - If no digits match: "Sorry, you did not win" gets printed on the screen by your code. - If the user entered anything other than a valid 3-digit (positive) integer, your program should warn her/him: "Please try again: enter a positive 3-digit number" (Note: you need to use the Math.random method from Chapter 4 in this problem; for the rest of this assignment, Java features just from Chapters 1 - 3 in Liang suffice.) EXAMPLE: Assume the lottery number is 123 and that Mary picked 100, Bob picked 217 and Ivan picked 723. Then Mary would win $10 (as only one digit matches '123' at the correct position), Bob would not win anything and Ivan would win $500 for two matched digits

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

Medical Image Databases

Authors: Stephen T.C. Wong

1st Edition

1461375398, 978-1461375395

More Books

Students also viewed these Databases questions

Question

How to find if any no. is divisble by 4 or not ?

Answered: 1 week ago

Question

Explain the Pascals Law ?

Answered: 1 week ago

Question

1. Prepare a flowchart of Dr. Mahalees service encounters.

Answered: 1 week ago