Question: Write a C++ program to run a menu driven program with the following choices: Reverse a number Compute the factorial of a number Computer the

Write a C++ program to run a menu driven program with the following choices:

  1. Reverse a number
  2. Compute the factorial of a number
  3. Computer the superfactorial of a number
  4. Quit

Make sure your program conforms to the following requirements:

1. Write a function called getValidUserInputPosNumGT0 that allows a user to enter in an integer and validated that the number is > 0. It must have a pass by reference parameter that will store the value selected by the user.

2. Write a function called reverse that takes a number as a value parameter and returns the reversed number.

3. Write a function called factorial that takes a number as a value parameter and returns the factorial of the number.

n! = n * (n-1) * (n-2) * ...1

4. Write a function called Superfactorial that takes a number as a value parameter and returns the Superfactorial of the number.

sf(n) = 1n* 2(n-1)* 3(n-2)* ...n1

You can use the pow function to calculate xi.

5. Add comments wherever necessary.

Sample Run:

Welcome to the playing with numbers! 1) Reverse a number 2) Compute the factorial of a number 3) Computer the superfactorial of a number 4) Quit Select an option (1..4)..1 Enter in a positive number greater than 0...12345 Reverse(12345)= 54321 1) Reverse a number 2) Compute the factorial of a number 3) Computer the superfactorial of a number 4) Quit Select an option (1..4)..2 Enter in a positive number greater than 0...3 Factorial(3) = 6 1) Reverse a number 2) Compute the factorial of a number 3) Computer the superfactorial of a number 4) Quit Select an option (1..4)..1 Enter in a positive number greater than 0...32 Reverse(32)= 23 1) Reverse a number 2) Compute the factorial of a number 3) Computer the superfactorial of a number 4) Quit Select an option (1..4)..3 Enter in a positive number greater than 0...2 SuperFactorial(2) = 2 1) Reverse a number 2) Compute the factorial of a number 3) Computer the superfactorial of a number 4) Quit Select an option (1..4)..3 Enter in a positive number greater than 0...3 SuperFactorial(3) = 12 1) Reverse a number 2) Compute the factorial of a number 3) Computer the superfactorial of a number 4) Quit Select an option (1..4)..6 Select an option (1..4)..0 Select an option (1..4)..-7 Select an option (1..4)..3 Enter in a positive number greater than 0...4 SuperFactorial(4) = 288 1) Reverse a number 2) Compute the factorial of a number 3) Computer the superfactorial of a number 4) Quit Select an option (1..4)..4

Process finished with exit code 0

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 Programming Questions!