Question: Need code in c++ Write a program to display a menu of 4 options, one for calling each of the functions you will define, below

Need code in c++

Write a program to display a menu of 4 options, one for calling each of the functions you will define, below and an option to terminate the program. The menu must be run in a continuous loop providing options to choose from. Option 1 calls function 2, option 2 calls function 3, option 3 calls function 4, option 4 calls function 5, and option 5 ends the program. The program must run in a continuous loop until the user wishes to quit. Choose descriptive function names. Avoid using function names such as function1, function2, etc.

Process and sample run:

a) Function 1: A void function to display a menu of choices.

b) Function 2: A void function that accepts the number of lines as its parameter for creating the following pattern. The function simply displays the pattern. For the given example, the number of lines is 4. 4 3 2 1 3 2 1 2 1 1 If the number of lines is more than 10, do not display a pattern and display a simple error message.

c) Function 3: An int function that accepts 3 integer parameters. Calculate and return the product of all integers between (inclusive) the first and second number with the step size identified by the third number. : If the first number is more than the second number, return -999. For example, if the parameter values are 10, 1, 3, the function returns -999. If the parameter values are 1, 10, 3, the function returns 1*4*7*10 = 280. If the parameter values are -5, 7, 2, the product should be: -5*-3*-1*1*3*5*7 = -1575. This function does not display the product; it just returns the value of the calculated product or it returns the error code -999.

d) Function 4: A double function that accept one integer parameter representing the number of test scores to be averaged. Inside the function, ask the user for the CIT133-Assignment 7 Chapter 6 Page 2 indicated number of test scores and calculate and return the average of the numbers. These test scores can be any number (decimal or floating point). Inside the function, return -1 if the number of items is 1 or less. For example, if the value of the parameter is -2, the function returns -1. If the value of the parameter is 5, the function should ask for 5 test scores and return the average. This function does not display the average; it just returns the value of the calculated average or it returns the error code -1.

e) Function 5: A double function that accepts income, consulting time, and the regular hourly rate and return consulting charges. If a person has an income of less than or equal to $25000 and the consulting time is 30 minutes or less, there are no charges. Otherwise, the charges are 40% of the regular hourly rate for the time over 30 minutes. For others, if the consulting time is 20 minutes or less, there are no service charges. Otherwise, charges are 70% of the regular hourly rate for the time over 20 minutes. For example, if a person has low income (<= $25000) and spent 75 minutes, and the hourly rate is $70, then the charges will be: (75-30)/60*.4*70 = $21.00. If a person makes more than the low income threshold of $25000 and spends 40 minutes, then the charge will be: (40-20)/60 * .7 * 70 = $16.33. Display 2 digits after the decimal point. Create named constants where feasible.

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!