Page 1 of 1

IMPORTANT: Your programs MUST get input, create variables, do calculations, and format as instructed. Your programs must

Posted: Mon May 09, 2022 6:04 am
by answerhappygod
IMPORTANT: Your programs MUST get input, create variables, do
calculations, and format as instructed. Your programs must use
functions where requested and should use the right type of
functions (see the important note below). Do not just hard-code the
output to get the auto-grader to work, I WILL check the code and if
you follow directions you will not get very many points even if the
code compiles and matches the test output.
Do not forget to put your name, CSIS 135, and Lab# in comments
at the top of each .cpp file. I will sometimes need to download and
maybe print your code.
Make sure that the prototypes and any named constants are in the
header file, the function definitions in the implementation file,
and have a separate file that has main.
REGARDING PSEUDOCODE: Pseudocode is required for this program.
This is a more difficult program so doing pseudocode WILL HELP.
IMPORTANT NOTE: Make sure and use the required functions as
indicated in the instructions for this program! NO GLOBAL VARIABLES
– no exceptions. Programs with global variables will not be
accepted (global constants are fine)
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.
Use srand(13) in the main to get consistent values for test.
Step 2:
Display the following menu:
LITTLETON CITY LOTTO MODEL:
---------------------------
1) Play Lotto
q) Quit Program
Please 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 userTicketarray.
The lotto does NOT have duplicate numbers in it. Find a way to not
allow duplicate numbers to be picked by the user. You will 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
userTicketarray 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. Use the noDuplicates
function to check for duplicates in the winningNums array.
Note: do NOT call the srand function in genWinNums (the srand is
done the main ONLY).
d. The next step is to check the user’s lotto ticket
(represented by the userTicketarray) 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.
Note: you can use the setfill('0') function to zero fill to the
left of the digits. For example, if num is 5:
cout << setfill('0') << setw(2) << num;
Would generate:
05
Test Case 1
Please enter your name: Mustang SallyENTER

\n
LITTLETON CITY LOTTO MODEL:\n
---------------------------\n
1) Play Lotto\n
q) Quit Program\n
Please make a selection: 1ENTER
Enter item #1: 11 5 8 49 4 22 32 40ENTER

Enter item #2: Enter item #3: Enter item #4: Invalid entry\n

Enter item #4: Enter item #5: Enter item #6: Enter item #7: \n

Mustang Sally's LOTTO RESULTS\n
---------------------\n
WINNING TICKET NUMBERS: 11 22 40 32 05 25 33 \n

Mustang Sally?S TICKET : 11 05 08 04 22 32 40 \n

\n
RESULTS:\n
--------\n
Number Matches: 5\n
Winnings : LUCKY YOU! - $5,000\n

\n
LITTLETON CITY LOTTO MODEL:\n
---------------------------\n
1) Play Lotto\n
q) Quit Program\n
Please make a selection: xENTER
Invalid selection\n
\n
LITTLETON CITY LOTTO MODEL:\n
---------------------------\n
1) Play Lotto\n
q) Quit Program\n
Please make a selection: 1ENTER
Enter item #1: 17 23 10 -4 6 16 26 36ENTER

Enter item #2: Enter item #3: Enter item #4: Invalid entry\n

Enter item #4: Enter item #5: Enter item #6: Enter item #7: \n

Mustang Sally's LOTTO RESULTS\n
---------------------\n
WINNING TICKET NUMBERS: 36 10 12 07 20 23 15 \n

Mustang Sally?S TICKET : 17 23 10 06 16 26 36 \n

\n
RESULTS:\n
--------\n
Number Matches: 3\n
Winnings : FREE TICKET\n

\n
LITTLETON CITY LOTTO MODEL:\n
---------------------------\n
1) Play Lotto\n
q) Quit Program\n
Please make a selection: 1ENTER
Enter item #1: 1 39 22 6 7 7 3 12ENTER

Enter item #2: Enter item #3: Enter item #4: Enter item #5: Enter item #6: Duplicate entry!\n

Enter item #6: Enter item #7: \n

Mustang Sally's LOTTO RESULTS\n
---------------------\n
WINNING TICKET NUMBERS: 12 04 38 09 35 34 10 \n

Mustang Sally?S TICKET : 01 39 22 06 07 03 12 \n

\n
RESULTS:\n
--------\n
Number Matches: 1\n
Winnings : SORRY NOTHING\n

\n
LITTLETON CITY LOTTO MODEL:\n
---------------------------\n
1) Play Lotto\n
q) Quit Program\n
Please make a selection: qENTER