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 15:00
The three logical operators used to write compound conditions are "and," "or," and "not." a: true b: false
Answers: 2
question
Computers and Technology, 23.06.2019 15:20
In a game with three frames, where will the objects on layer 1 appear? a. next to the play area b. in the middle of the game c. behind everything else d. in front of everything else
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
Suppose a cpu with a write-through, write-allocate cache achieves a cpi of 2. what are the read and write bandwidths (measured by bytes per cycle) between ram and the cache? (assume each miss generates a request for one block.)
Answers: 1
question
Computers and Technology, 24.06.2019 03:00
Click the "draw structure" button to activate the drawing utility. draw two diastereomers of (1z,4r)−1,4−dimethylcyclodecene and name them, including (e)/(z) and (r)/(s) notation. part 1 out of 4 draw the diastereomer containing a chiral center with s configuration here. window open
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, 24.09.2020 22:01
question
History, 24.09.2020 22:01
question
Mathematics, 24.09.2020 22:01
Questions on the website: 13722362