Question: C++ The program will prompt the user for the following information: The number of values to print out ranging from 3 to 7 (inclusive). Any

C++

  1. The program will prompt the user for the following information:
    1. The number of values to print out ranging from 3 to 7 (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-45 to 1-70 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 in 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 3 and 7 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.

Sample Run:

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

The number must be between 3 and 7: 7

Enter in the largest number in the lottery.

The number must be between 45 - 70: 55

Enter the number of tickets 1-100 inclusive: 25

You will select 7 numbers

The numbers will range from 1 to 55

The odds are 1 in 2029727725

YOUR LOTTERY SELECTIONS ARE:

34 38 47 18 30 2 27

26 46 48 21 7 11 13

42 37 40 51 14 18 27

47 28 18 38 6 37 19

44 2 39 26 35 1 55

37 14 25 6 4 35 12

1 34 40 37 5 36 38

22 49 29 53 12 41 34

17 29 23 55 41 2 27

25 55 38 39 5 41 4

29 38 43 10 30 47 51

4 8 32 1 19 17 22

35 33 44 34 5 32 20

32 2 6 14 40 10 42

31 13 15 55 43 24 29

39 16 25 42 23 43 30

28 4 38 49 23 26 14

28 44 20 4 45 25 17

16 34 3 46 17 33 8

28 6 46 30 17 20 52

4 36 11 8 18 17 30

17 44 18 36 47 50 51

52 12 40 30 32 44 7

39 16 12 17 45 23 28

19 3 38 13 7 28 30

GOOD LUCK

Here is what I have so far:

//header files #include #include #include #include using namespace std; //function to calculate factorial int factorial(int f) { //set fact to 1

int fact=1; //loop => i from 3 to f for(int i=3;i<=f;i++) { //do this fact=fact*i; } //return fact return fact; } //function which checks if t is already present in arr or not bool dup(int c,int *arr,int t) { //loop to check for(int i=0;ib;i--) { //do this f=f*i;

} //return f return f; } //main function int main() { //declare variables int num; int large; int ticket; int *a; //set seed of time(0) srand(time(0)); int t; int c=0; cout<<"Enter in the number of balls or numbers you wish to pick from."; //taking input number from user cout<<" The number must be between 3 and 7: "; //storing it in num cin>>num; //run this loop if entered number num is out of range(3-7) while(num<3 || num>7) { //ask user to enter again cout<<"Enter again: "; //store it in num cin>>num; } //allocate memory of num integer to array a a=new int[num]; cout<<"Enter in the largest number in the lottery. "; //asking user to enter upper value for range cout<<"The number must be between 45-70: "; //store it in large cin>>large; //run this loop if entered number num is out of range(45-70) while(large < 45 || large > 70) { //ask user to enter again cout<<"Enter again: "; //store it in num cin>>large;

} //asking user to enter number of tickets cout<<"Enter the number of tickets 1-100 inclusive: "; //store it in ticket cin>>ticket; //run this loop if entered number ticket is out of range(1-100) while(ticket<1 || ticket>100) { //ask user to enter again cout<<"Enter again: "; //store it in ticket cin>>ticket;

} //print cout<<"You will select "<

} //print a[j] with a space cout<

My output doesn't match the sample run and the factorial is incorrect. Please help C++

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!