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:
- Reverse a number
- Compute the factorial of a number
- Computer the superfactorial of a number
- 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
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