- 2

6. Generate a three-digit lottery number.

The program prompts the user to enter a three-digit number and determines whether the user wins according to the following rules: a. If the user input matches the lottery number in the exact order, the award is $10,000. b. If all the digits in the user input match all the digits in the lottery number, the award is $3,000. c. If one digit in the user input matches a digit in the lottery number, the award is $1,000.

4th Jun 2022, 7:49 AM
minahil ashfaq
10 Antworten
+ 1
Do you have a code that doesn't work? We'd love to see it and then someone can help. Attach it here from the code playground.
4th Jun 2022, 8:02 AM
Ausgrindtube
Ausgrindtube - avatar
+ 1
I think you might need to look at how you take in user input. Then, you want to compare the user's 3 digits exactly to the "lottery" digits. If that doesn't match, compare each digits individually. I would iterate through an array. If any one of those digits matches, then the user wins $1,000. If all 3 match, $3,000. If none match... nothing.
4th Jun 2022, 8:22 AM
Ausgrindtube
Ausgrindtube - avatar
+ 1
Thank u :)
4th Jun 2022, 8:37 AM
minahil ashfaq
+ 1
Are you asking for an algorithms or what? Which language do you want to code with?
4th Jun 2022, 10:49 PM
Akang Toshi
Akang Toshi - avatar
+ 1
I'm a beginner learning python Thank u everyone...I have done that
4th Jun 2022, 10:51 PM
minahil ashfaq
0
import random a=random.randint(0,9) import random b=random.randint(0,9) import random c=random.randint(0,9) print (a,b,c)
4th Jun 2022, 8:05 AM
minahil ashfaq
0
Can't understand what to do next
4th Jun 2022, 8:05 AM
minahil ashfaq
0
minahil ashfaq I note that you haven't commenced any courses, which may explain why you don't know how to proceed. Start doing the courses, and you will start to develop the solutions.
4th Jun 2022, 10:15 AM
Rik Wittkopp
Rik Wittkopp - avatar
4th Jun 2022, 11:40 PM
Akang Toshi
Akang Toshi - avatar
0
Input 3 digits auto generate 3 digits with code in JavaScript
10th May 2023, 6:21 AM
Jermaine Mae Bonete
Jermaine Mae Bonete - avatar