Write a program that prints a menu

Assignment Help Computer Engineering
Reference no: EM131884682

Assignment

Part 1

Write a program that prints a menu. Based on the menu item selected by the user, the program should

• request the required inputs from the user
• call the appropriate function
• print the function's result (from the main program NOT the function)

For example, if the user selections the sum function, then your program will ask them for two numbers to be added together, call the sum function, and finally print the sum function's result.

NOTE: In case of a typo on here - make your output match the CA output!

The functions to implement are:

1. Simple Sum: Takes two int parameters and returns their sum. You will need to ask the user for two integers before calling this function.

2. Simple Division: Takes two int parameters and returns their floating point quotient (e.g., 10/3 returns 3.33). You will need to ask the user for two integers before calling this function.

3. Complex Division: Takes four int parameters, sums the first three parameters and then divides the sum by the fourth parameter. Returns the floating point quotient (e.g., (10 + 7 + 5) / 4 returns 5.5). You will need to ask the user for three integers and an integer divisor before calling this function.

Design:

1. It is imperative that each of these three operations be in their own function.

2. You should have an additional function that determines the operation type by printing the menu and then returning the integer that the user selects.

3. Your main program should use a switch statement that switches on the numeric integer entered by the user to select the correct function to call.

1. Your switch statement should also gather the inputs from the user before calling the function.
2. You will print the result returned by the function in your switch statement.

4. All function prototypes will be listed at the top of your code (after using namespace std;) and all your function definitions to be placed after main.

Sample Output: Here is a sample user interaction with the program (user inputs are highlighted in blue) - Please see Code Assessor output for exact spacing and newlines.

Please make a selection from the following menu

1. Simple Sum
2. Simple Division
3. Complex Division

Enter the number of the operation you wish to perform: 3

Please enter four integers: 10 7 5 4

quotient = 5.5
More Functions - Part 2

This part will give you more practice using functions such as the pre-defined functions and loops. Remember to include the cmath library, which contains the required pre-defined functions for this lab. Add the following functions to your menu and implement them:

1. Max: Takes three int parameters and returns their maximum value. You will need to ask the user for three integer values before calling this function.

2. Hypotenuse: Takes two floating point variables which are the lengths of the two sides of a triangle, and returns the floating point length of the third side of the triangle (the third side is called the hypotenuse). The equation for the length of the hypotenuse is a2 +b2=c2 You will need to ask the user for two floating point numbers before calling this function.

3. Cubic Equation: Takes four floating point coefficients for the cubic equation ax3+bx2+cx+d plus the value of x and returns the result. You must use the pow function to compute x3 and x2. You will need to ask the user for four coefficients (a, b, c, d) and the value of x before calling this function.

***IN ADDITION*** Add the ability to let the user repetitively enter menu options until they enter the numeric code for quit (for this phase it is item 9).

Sample Output:Here is a sample interaction with the program (user input highlighted in blue):

Please make a selection from the following menu

1. Simple Sum
2. Simple Division
3. Complex Division
4. Max
5. Hypotenuse
6. Cubic Equation
7.
8.
9. Quit

Enter the number of the operation you wish to perform: 5

Please enter the two side lengths: 3.5 4.9

hypotenuse = 6.02163Please make a selection from the following menu

1. Simple Sum
2. Simple Division
3. Complex Division
4. Max
5. Hypotenuse
6. Cubic Equation
7.
8.
9. Quit

Enter the number of the operation you wish to perform: 6

Please enter four coefficients and x: -3.5 5.848 58.588 586 -4.576

cubic result = 775.729
Please make a selection from the following menu
1. Simple Sum
2. Simple Division
3. Complex Division
4. Max
5. Hypotenuse
6. Cubic Equation
7.
8.
9. QuitEnter the number of the operation you wish to perform: 9

When the user types 9 for quit, your program must exit.

Still More Functions Part 3

In this part you will get experience writing void functions that return more than one result via reference parameters. Write the following two functions and add them to your menu:

1. MinMax: Takes 5 parameters, the first three are user-supplied inputs and the last two are "result" parameters. Place the smallest of the first three parameters into the fourth parameter (min) and the largest of the three parameters in the fifth parameter (max). When MinMax returns, the calling function will examine the fourth and fifth arguments and find the values placed there by MinMax. For example, if MinMax were called as:

int x = 3, y = 10, z = 1;
int min, max;
MinMax(x, y, z, min, max);

then min will be 1 and max will be 10 when MinMax returns. You will need to ask the user for three integers before calling this function.

1. Modulus: Takes 4 int parameters, the first two are user-supplied inputs and the last two are the quotient and remainder. The quotient is calculated by dividing the first parameter by the second parameter. The remainder is whatever is left after division. For example, if Modulus were called as follows:

int x = 17, y = 3;
int quotient, remainder;
Modulus(x, y, quotient, remainder);

then quotient will be 5 and remainder will be 2 after Modulus returns. You will need to ask the user for two integers before calling this function.

Sample Output: Here is a sample interaction with the program (user input is highlighted in blue):

Please make a selection from the following menu

1. Simple Sum
2. Simple Division
3. Complex Division
4. Max
5. Hypotenuse
6. Cubic Equation
7. MinMax
8. Modulus
9. Quit

Enter the number of the operation you wish to perform: 7

please enter three integers: 3 8 2
min = 2
max = 8

Please make a selection from the following menu

1. Simple Sum
2. Simple Division
3. Complex Division
4. Max
5. Hypotenuse
6. Cubic Equation
7. MinMax
8. Modulus
9. Quit

Enter the number of the operation you wish to perform: 8

please enter two integers: 17 3

quotient = 5
remainder = 2

Please make a selection from the following menu

1. Simple Sum
2. Simple Division
3. Complex Division
4. Max
5. Hypotenuse
6. Cubic Equation
7. MinMax
8. Modulus
9. Quit

Enter the number of the operation you wish to perform: 9

When the user types 9 for quit, your program must exit.

Reference no: EM131884682

Questions Cloud

What is your monthly piti payment if you escrow the taxes : Property Taxes are 120 Mills with 80 Effective Mills. What is your Monthly PITI Payment if you escrow the taxes and insurance?
What are the prices of the bond when interest rates increase : Using duration what are the prices of the two bonds when interest rates increase by 200 basis points. By a 75-basis point increase? Why?
What should tampico enterprises consider doing : Tampico Enterprises inventory turnover was 8.2 in 2X10. After analyzing several similar, competing companies, Tampico Enterprises found that the average.
What budget models is the application best applied : Discuss how the calculation of the coefficient of variation (ratio of the standard deviation to the mean) can be applied in budget variance analysis.
Write a program that prints a menu : Write a program that prints a menu. Based on the menu item selected by the user, the program should request the required inputs from the user.
What is ownership of the parties after full ratchet : Suppose founders own 70% of company ING and VC's preferred stock shares are convertible at $1 per share. VC#1 has already put in $5M.
What will be the cost savings in 2013 : suming these costs increase with inflation, and the inflation rate is 4 percent, what will be the cost savings in 2013?
What is a standard cost : What is a standard cost? Provide an example of a manufacturing standard cost. What is an ideal standard?
Create a park on some vacant property on the outskirts : A community wants to create a park on some vacant property on the outskirts of the town (zoned commercial).

Reviews

Write a Review

Computer Engineering Questions & Answers

  Go online and conduct a search on customer affinity choose

identify and provide the url a web site you visit frequently and identify 3 features of the site that cause you to

  Relationship between programming languages and applications

The consultants suggested using object-oriented technology. still the internal information systems team was hesitant to use object-oriented technology. They instead suggested using structured programming.

  Define the hoare semantics

Assuming Hansen semantics for condition variables, our implementation of the blocking bounded queue in Figure does not guarantee freedom from starvation.

  Explain the purpose of the ethical hacking concept

Explain the purpose of the ethical hacking concept. Outline legal assessments on remote/foreign networks.3. Describe the role of an ethical hacker. Present what an ethical hacker can do legally at the state level.

  Describe how you will keep in contact with the client

Describe how you will keep in contact with the client and report progress, and how you will communicate among your team.

  Identify the convection diffusion and source terms

The construction of the boundary-layer equations for momentum and energy boundary-layer equations for momentum, their turbulent counterparts.

  Demonstrate understanding of arithmetic operations

Write a text file with the original number in it, and then all the user should enter a number to guess and the computer responses between pico, fermi

  Define the necessary project management skills to accomplish

be sure that you briefly describe why each of the listed tasks is critical to the success of the project and how each of the listed skills helps the project manager.

  Find out your letter grade based on your exam score

Write down a grading program that helps to determine your letter grade based on your exam score.

  Develop a program that used to determine election results

Develop a program that could be used to determine election results for a town. Assume that the town is divided into a number of precincts.

  What is the variety of addresses available in each networks

What is the variety of addresses available in each  networks

  In what ways can an html form element acquire focus

In what ways can an HTML form element acquire focus? Describe the approach to addressing HTML elements using forms and elements.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd