Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ Write a program that simulates a lottery. The program should have an array of five integers named lottery, and should generate a random number
C++
Write a program that simulates a lottery. The program should have an array of five integers named lottery, and should generate a random number in the range of O through 9 for each element in the array. The user should enter five digits which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that match. For example, the following show the lottery array and the user array with sample numbers stored in each. There are two matching digits (elements 2 and 4). lottery: 7 4 9 1 3 user: 4 2 9 7 3 The program should display the random numbers stored in the lottery array and the number of matching digits. If all of the digits match, display a message proclaiming the user as the grand prize winner. You must: 1. Complete as much as possible of this problem in the time allotted. 2. Submit your work to the discussion board 3. Comment on two class mates code. Compile and run each program, then critique the work for: proper variable naming . proper code indentation o correctness of the algorithm each loop must have exactly one entry point, and one exit point. The use of the break statement to exit a loop is unacceptable. Do your best to give suggestions on how the program might be improved
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started