Question
Write a C++ program to run a menu-driven program with the following choices: Count number of even digits in a number Compute the factorial of
Write a C++ program to run a menu-driven program with the following choices:
- Count number of even digits in a number
- Compute the factorial of a number
- Quit
Make sure your program conforms to the following requirements: 1. This program should be called playingWithNumbers.cpp
2. Write a function called getValidUserInputPosNumGT0 that allows a user to enter 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.
3. Write a function called numEvenDigits that takes a number as a value parameter and returns the count of how many digits in the number are even.
4. 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
5. Add comments wherever necessary.
Sample Runs:
NOTE: not all possible runs are shown below.
Sample Run
Welcome to the playing with numbers! 1) Count the even digits in a number 2) Compute the factorial of a number 3) Quit Select an option (1..4)..9 Select an option (1..4)..-9 Select an option (1..4)..1 Enter in a positive number greater than 0...12 numEvenDigits(12)= 1 1) Count the even digits in a number 2) Compute the factorial of a number 3) Quit Select an option (1..4)..1 Enter in a positive number greater than 0...22 numEvenDigits(22)= 2 1) Count the even digits in a number 2) Compute the factorial of a number 3) Quit Select an option (1..4)..1 Enter in a positive number greater than 0...1345 numEvenDigits(1345)= 1 1) Count the even digits in a number 2) Compute the factorial of a number 3) Quit Select an option (1..4)..1 Enter in a positive number greater than 0...2461 numEvenDigits(2461)= 3 1) Count the even digits in a number 2) Compute the factorial of a number 3) Quit Select an option (1..4)..2 Enter in a positive number greater than 0...1 Factorial(1) = 1 1) Count the even digits in a number 2) Compute the factorial of a number 3) Quit Select an option (1..4)..2 Enter in a positive number greater than 0...2 Factorial(2) = 2 1) Count the even digits in a number 2) Compute the factorial of a number 3) Quit Select an option (1..4)..2 Enter in a positive number greater than 0...3 Factorial(3) = 6 1) Count the even digits in a number 2) Compute the factorial of a number 3) Quit Select an option (1..4)..2 Enter in a positive number greater than 0...4 Factorial(4) = 24 1) Count the even digits in a number 2) Compute the factorial of a number 3) Quit Select an option (1..4)..2 Enter in a positive number greater than 0...5 Factorial(5) = 120 1) Count the even digits in a number 2) Compute the factorial of a number 3) Quit Select an option (1..4)..3
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