Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

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:

  1. Count number of even digits in a number
  2. Compute the factorial of a number
  3. Quit

Make sure your program conforms to the following requirements:

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. (10 points).

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. (20 points).

4. Write a function called factorial that takes a number as a value parameter and returns the factorial of the number. (20 points).

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

5. Add comments wherever necessary. (5 points)

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..3)..9 Select an option (1..3)..-9 Select an option (1..3)..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..3)..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..3)..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..3)..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..3)..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..3)..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..3)..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..3)..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..3)..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..3)..3

Process finished with exit code 0

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions