subject

You’re going to write a program that models the littleton city lotto (not a real lotto game). the program is going to allow to user to first select their lotto numbers. the program will then randomly generate the winning lotto numbers for the week and then check the winning numbers against the random ticket the user played in the lotto to see how many numbers the user guessed correctly.
the rules for lotto work as follows:
1. select 7 numbers between 1 and 40
2. twice every week 7 numbers are drawn at random
3. if a player matches all 7 numbers they win a million dollar prize
4. if a player matches 6 numbers they win $100,000
5. if a player matches 5 numbers they win $5,000
6. if a player matches 4 numbers they win $100.
7. if a player matches 3 numbers they win a free ticket.
your program should work as follows. (note i have listed some functions you need to include in your program – you may include other functions if you would like and they make your program more readable/efficient).
step 1:
create an array named userticket to hold each of the user’s lotto number selections.
create an array named winningnums to hold the winning lotto numbers.
step 2:
display the following menu:
littleton city lotto model:

1) play lotto
q) quit program
make a selection:
-if the selection is 1:
a. first ask the user their name and store it in an appropriate variable.
b. next, call a function named getlottopicks that asks the user to enter their 7 lotto number picks (selections) for the week. each of the user’s lotto picks should be stored in the userticket array. the lotto does not have duplicate numbers in it. find a way to not allow duplicate numbers to be picked by the user. you may want to create another function called noduplicates that checks to see if the user’s selection is already in the userticket array. if the user enters a number already in the array, ask them to enter another number until they enter one that is not a duplicate. this means the userticket array should contain no duplicate numbers.
c. next, call a function named genwinnums that randomly generates the winning lotto numbers for the week based on the rules stated above and stores the winning lotto numbers in the winningnums array (so you are going to fill the winningnums array with random numbers between 1 and 40). do not allow this function to generate duplicate winning numbers (if you design your noduplicates function above well you should be able to re-use it to check for duplicates in the winningnums array).
hint: there are two ways to avoid having duplicate numbers in an array. most of you will need to use the first method. the first method is to check the array after each number is generated or entered to make sure that number is not already in the array. if the number generated/entered is already in the array a new number should be generated/entered. the second method involves sorting and checking that the numbers next to each other in the array after the sort are not the same – if you have taken csis 130 and know how to sort an array you can use this method.
d. the next step is to check the user’s lotto ticket (represented by the userticket array) to see if they have won any prizes in the lotto game. check each number the userticket array to see if that number is in the winningnums array and count how many numbers are matched.
display a report similar to the following showing user’s lotto results – the example output below assumes the user entered a name of "julie" when the program started.
in the "winnings" section of the report
¨ display: jackpot - 1 million if all 7 numbers were correct
¨ display: great! - $100,000 if 6 numbers were correct
¨ display: lucky you! - $5,000 if 5 numbers were correct
¨ display: not bad - $100 if 4 numbers were correct
¨ display: free ticket if 3 numbers were correct
¨ display: sorry nothing if 2 or less numbers were correct
julie's lotto results

winning ticket numbers: 35 03 01 15 10 25 22
julie’s ticket : 33 15 02 06 21 20 19
results:

number matches: 1
winnings : sorry nothing
-if the selection is q: quit the program
-if the selection is not q and not 1: display an invalid selection message
allow the user to play lotto as many times as they would like.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 20:00
Which type of file can be used to import data into a spreadsheet?
Answers: 1
question
Computers and Technology, 23.06.2019 13:50
Explain how email technologies enable the exchange of messages between users. find out the typical parts of an email address and explain each part.
Answers: 1
question
Computers and Technology, 23.06.2019 23:30
Perform an online search about the booting process of a computer and list all the steps
Answers: 2
question
Computers and Technology, 24.06.2019 09:50
Self contained sequences of actions to be performed are? a. expressions b. algorithms c. functions d. formulas
Answers: 1
You know the right answer?
You’re going to write a program that models the littleton city lotto (not a real lotto game). the pr...
Questions
question
Mathematics, 16.09.2021 14:50
question
Arts, 16.09.2021 14:50
question
Mathematics, 16.09.2021 14:50
Questions on the website: 13722363