Write a program that randomly generates a lottery between 100 and 999 (random.randint(100, 999)), prompts the user to enter a number in the same range, and determines whether the user wins according to the following rule: (1) If the user input matches the lottery in exact order, print "the award is $10,000". E.g., lottery = 123, input = 123 (2) If the user input matches the lottery, but in wrong order, print "the award is $6,000". E.g., lottery = 123, input = 321 (3) If two digits in the user input matches a digit in the lottery, print "the award is $3,000". E.g., lottery = 123, input = 612 (4) If one digit in the user input matches a digit in the lottery, print "the award is $1,000". E.g., lottery = 123, input = 289 (5) If none of the digits is matched, print "thank you".

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter5: Repetition Statements
Section: Chapter Questions
Problem 7PP
icon
Related questions
Question

-scripting language

Write a program that randomly generates a lottery between 100 and 999 (random.randint(100, 999)), prompts the user to enter a number in the same range, and determines whether the user wins according to the following rule:

(1) If the user input matches the lottery in exact order, print "the award is $10,000". E.g., lottery = 123, input = 123
(2) If the user input matches the lottery, but in wrong order, print "the award is $6,000". E.g., lottery = 123, input = 321
(3) If two digits in the user input matches a digit in the lottery, print "the award is $3,000". E.g., lottery = 123, input = 612
(4) If one digit in the user input matches a digit in the lottery, print "the award is $1,000". E.g., lottery = 123, input = 289
(5) If none of the digits is matched, print "thank you".

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Constants and Variables
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning