Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This program will be ran through a Python 3 IDE, please use correct formatting a

ID: 3691628 • Letter: T

Question

This program will be ran through a Python 3 IDE, please use correct formatting as such.

Write a function named lottery() that takes an integer n as input and that can be used to generate 6 lottery numbers in the range from 1 to 60 without replacement. Each number, selected uniformly at random without replacement from the range 1 through 60, should be printed after pressing the Enter/Return key. The program should terminate after the 6th number has been printed.

Here is an example of how the function should work:

>>> lottery(60)

27

10

58

28

60

2

Explanation / Answer

//======================================================================================= // Constant Declarations // --------------------- const int lotteryDigits = 60; const int SIZE = 6; //==== // Function Prototypes // ------------------- int generateLottery(int[], int, int); int userInput(int[], int); int matchCounter(int[], int[], int); void displayNumbers(int[], int[]); void winnerOrLoser(int); //========= // ------------- // Main Function // ------------- //======================================================================================= using namespace std; int main() { // Variable Declarations int lottery[6] = {0, 0, 0, 0, 0}; int user[6] = {0, 0, 0, 0, 0}; int matches = 0; //Function Calls generateLottery(lottery, SIZE, lotteryDigits); userInput(user, SIZE); matchCounter(lottery, user, matches); displayNumbers(lottery, user); winnerOrLoser(matches); system("pause"); return 0; } //end main //================ // -------------------- // Function Definitions // -------------------- //================ // Randomly generates winning lottery numbers int generateLottery(int lottery[], int, int) { unsigned seed = time(0); srand(seed); for (int y=0; y> user[y]; } } return user[0], user[1], user[2], user[3], user[4]; } // end userInput //=================== // Counts the number of matches int matchCounter(int lotto[], int input[], int) { int match = 0; for (int x = 0; x
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote