Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

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.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M92713029

Have any Question?


Related Questions in Computer Engineering

Question in this assignment you will begin to create your

Question: In this assignment, you will begin to create your own formal website plan by defining the website's goals and objectives, writing a formal purpose statement, and creating a target audience profile and needs ass ...

What is the process involved in answering this

What is the process involved in answering this question? Stock Index Performance   On November 27, 2007, The Dow Jones Industrial Average closed at 12,958.44, which was up 215.04 that day. What was the return (in percent ...

Question sunshine health corporation is seeking to improve

Question : Sunshine Health Corporation is seeking to improve overall connectivity across their corporate campus near the Hawaii Kai Marina, Honolulu, Hawaii. The campus buildings have recently been updated, thus the LANs ...

Assignment 1 multi-touch screens vs mouse-driven screensthe

Assignment 1: Multi-Touch Screens vs. Mouse-Driven Screens The following resources may be helpful when completing this assignment. • Dearden, A. (2008). User-Centered Design Considered Harmful • Norman, D. (2007-2010). A ...

Question discuss the advantages and disadvantages of

Question: Discuss the advantages and disadvantages of Incident Response testing. When is each type of testing appropriate? Are there situations that preclude the use of a particular type of testing? Requirement: I recomm ...

Discuss the importance of metadata and some of the various

Discuss the importance of metadata and some of the various ways (Microsoft) SQL Server allows you to expose that information. References welcomed to learn where to find obscure IT information (books, articles, websites)

Select a technology product process hardware software or

Select a technology (product, process, hardware, software, or any combination thereof). Laptop, Tablet, PDA 1. How do you characterize this technology (function, principle of operation, performance, etc.)? 2. Where does ...

As a wealthy graduate of the university you have decided to

As a wealthy graduate of the University, you have decided to give back to the University in the form of a scholarship. You have decided to donate a one-time gift of $500,000 that will be invested at a rate of 5.5% per ye ...

In 2015 caterpillar inc had about 757 million shares

In 2015, Caterpillar Inc. had about 757 million shares outstanding. Their book value was $41.0 per share, and the market price was $93.50 per share. The company's balance sheet shows that the company had $34.50 billion o ...

Subject oop javaassume you want to develop an application

Subject: OOP, Java Assume you want to develop an application like Microsoft Word, Microsoft Excel, Microsoft Paint, etc. in which multiple users are allowed to access the same file simultaneously from different locations ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As