Question: C++ assignment!!! The program will prompt the user for the following information: The number of values to print out ranging from 2 to 8 (inclusive).

C++ assignment!!!

  1. The program will prompt the user for the following information:

    1. The number of values to print out ranging from 2 to 8 (inclusive). Any values outside that range must be rejected and the user prompted to enter in correct values.

    2. The range of random numbers to consider. This will be the number of possible values to be selected. This value will range from 1-50 to 1-60 inclusive. You need only prompt for the last number since all lottery values will start with 1. Any values outside that range will be rejected and the user prompted to enter the correct values.

    3. The number of tickets that you wish to generate from 1 to 100 inclusive. Any value outside the range will be rejected and the user prompted to enter the correct value.

    4. Once a number is selected it cannot be selected again. You must have some method of avoiding duplicate numbers.

    5. You can assume that valid integers will be entered so you wont need to check for invalid characters or converting numbers.

  2. Output

    1. Echo the information that the user input.

      1. Number of numbers ( number between 2 and 8 inclusive)

      2. Range of Values ( 1 to the largest value)

      3. Number of ticket guesses (number of tickets)

      4. Odds of winning. To estimate the odds of winning you use a formula that uses the highest value and the number of numbers. So, if you wanted 6 numbers with a maximum value of 55 you would calculate the odds at: N! / (K! * (N-K)! where N is the highest number and K is the number of balls selected. 55*54*53*52*51*50/ (1*2*3*4*5*6) = 1 in 28,989,675

      5. The numbers produced by your program, one group per line. See Example.

Design Considerations:

  1. Provide an initial seed to your random number generator by pasting the current time to srand. . Be sure to include the , , and and libraries.

  2. Each subsequent call to rand() will cause a new seed to be generated automatically.

  3. The random number generator returns a large integer number which must have the modulo operator used to reduce the possible number of returned values for the range you wish. For instance, if you wanted the upper range of your numbers to be 56 you would use the following statements:

Randomnumber = rand() % 56 +1;

  1. Each number within a ticket can be used only once. Think of the ping pong ball method used on lottery shows where once a ball is selected that number cannot be used again.

  2. Your program must use functions that show examples of passing parameters and returning values.

Sample Run:

Enter in the number of balls or numbers you wish to pick from.

The number must be between 2 and 8: 8

Enter in the largest number in the lottery.

The number must be between 50 - 60: 55

Enter the number of tickets 1-100 inclusive: 25

You will select 8 numbers

The numbers will range from 1 to 50

The odds are 1 in 2029727725

YOUR LOTTERY SELECTIONS ARE:

34 38 47 18 30 2 27 42

26 46 48 21 7 11 13 9

42 37 40 51 14 18 27 45

47 28 18 38 6 37 19 21

44 2 39 26 35 1 55 33

37 14 25 6 4 35 12 26

1 34 40 37 5 36 38 30

22 49 29 53 12 41 34 15

17 29 23 55 41 2 27 22

25 55 38 39 5 41 4 32

29 38 43 10 30 47 51 40

4 8 32 1 19 17 22 10

35 33 44 34 5 32 20 22

32 2 6 14 40 10 42 41

31 13 15 55 43 24 29 16

39 16 25 42 23 43 30 40

20 28 4 38 49 23 26 14

43 28 44 20 4 45 25 17

22 16 34 3 46 17 33 8

35 28 6 46 30 17 20 52

4 36 11 12 8 18 17 30

17 44 18 26 36 47 50 51

52 12 27 40 30 32 44 7

39 16 12 17 45 26 23 28

19 3 38 13 15 7 28 30

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!