1 Calculate Areas calculateAreas.cpp contains several functions: calculateSquare, calculateCircle, calculateRight Triangle, printResult, and runProgram. runProgram is...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
1 Calculate Areas calculateAreas.cpp contains several functions: calculateSquare, calculateCircle, calculateRight Triangle, printResult, and runProgram. runProgram is a void function with no parameters. It is simply the function that the main function will call. printResult will take two arguments: the shape whose area is to be printed and the value of that shape's area. It will print the result of the given calculation. calculateAreas will display a menu to the user, read in the user's choices based on the menu, act on the user's choices, and (eventually) end the program when the user decides. calculateSquare will take the length of a square's side as an argument and return the area of a square with that given side length. The formula for the area of a square is A = s where A is area and s is the side length. Figure 1: Square of area 36 calculateCircle will take the length of a circle's radius as an argument and return the area of a circle with that given radius. The formula for the area of a circle is A = x where A is area, r is the radius length, and is defined as MPI in the cmath library. O Figure 2: Circle of area 36m calculateRight Triangle will take the length of a right triangle's base and the height of a right triangle and return the area of a right triangle with those given dimensions. The formula for the area of a right triangle is A = xbxh where b is the length of the base of the triangle and h is the height of the triangle. Figure 3: Right Triangle of area 18 1.1 Sample Run Sample Run ./calculate Areas.out Enter a shape calculate the area of (1: square, 2: circle, 3: right triangle, 4: quit): 1 Enter the length of the square's sides: 4 The area of the square is 16.00. Enter a shape calculate the area of (1: square, 2: circle, 3: right triangle, 4: quit): 2 Enter the radius of the circle: 2 The area of the circle is 12.57. Enter a shape calculate the area of (1: square, 2: circle, 3: right triangle, 4: quit): 3 Enter the length of the base and height of the triangle: 3 4 The area of the triangle is 6.00. Enter a shape calculate the area of (1: square, 2: circle, 3: right triangle, 4: quit): 4 #include "calculateAreas.h" #include #include // access to M PI constant #include #include #include using namespace std; int main(int argc, char* argv[]) { runProgram (); return 0; } void runProgram () { } } Author: Purpose: Functions to calculate areas of various geometric shapes void printResult( string shape, double area) { } return; void calculateAreas () { } return; } double calculateSquare ( double side) { return -1; return 0; double calculateCircle( double radius ) { return -1; double calculateRightTriangle( double base, double height ) { return -1; #ifndef CALCULATEAREAS H #define CALCULATEAREAS H #include using namespace std; Author: Purpose: Functions to calculate areas of various geometric shapes */ void runProgram (); void printResult( string shape, double area ); void calculate Areas (); double calculateSquare ( double side ); double calculateCircle( double radius ); double calculateRightTriangle ( double base double height ); #endif 1 Calculate Areas calculateAreas.cpp contains several functions: calculateSquare, calculateCircle, calculateRight Triangle, printResult, and runProgram. runProgram is a void function with no parameters. It is simply the function that the main function will call. printResult will take two arguments: the shape whose area is to be printed and the value of that shape's area. It will print the result of the given calculation. calculateAreas will display a menu to the user, read in the user's choices based on the menu, act on the user's choices, and (eventually) end the program when the user decides. calculateSquare will take the length of a square's side as an argument and return the area of a square with that given side length. The formula for the area of a square is A = s where A is area and s is the side length. Figure 1: Square of area 36 calculateCircle will take the length of a circle's radius as an argument and return the area of a circle with that given radius. The formula for the area of a circle is A = x where A is area, r is the radius length, and is defined as MPI in the cmath library. O Figure 2: Circle of area 36m calculateRight Triangle will take the length of a right triangle's base and the height of a right triangle and return the area of a right triangle with those given dimensions. The formula for the area of a right triangle is A = xbxh where b is the length of the base of the triangle and h is the height of the triangle. Figure 3: Right Triangle of area 18 1.1 Sample Run Sample Run ./calculate Areas.out Enter a shape calculate the area of (1: square, 2: circle, 3: right triangle, 4: quit): 1 Enter the length of the square's sides: 4 The area of the square is 16.00. Enter a shape calculate the area of (1: square, 2: circle, 3: right triangle, 4: quit): 2 Enter the radius of the circle: 2 The area of the circle is 12.57. Enter a shape calculate the area of (1: square, 2: circle, 3: right triangle, 4: quit): 3 Enter the length of the base and height of the triangle: 3 4 The area of the triangle is 6.00. Enter a shape calculate the area of (1: square, 2: circle, 3: right triangle, 4: quit): 4 #include "calculateAreas.h" #include #include // access to M PI constant #include #include #include using namespace std; int main(int argc, char* argv[]) { runProgram (); return 0; } void runProgram () { } } Author: Purpose: Functions to calculate areas of various geometric shapes void printResult( string shape, double area) { } return; void calculateAreas () { } return; } double calculateSquare ( double side) { return -1; return 0; double calculateCircle( double radius ) { return -1; double calculateRightTriangle( double base, double height ) { return -1; #ifndef CALCULATEAREAS H #define CALCULATEAREAS H #include using namespace std; Author: Purpose: Functions to calculate areas of various geometric shapes */ void runProgram (); void printResult( string shape, double area ); void calculate Areas (); double calculateSquare ( double side ); double calculateCircle( double radius ); double calculateRightTriangle ( double base double height ); #endif
Expert Answer:
Related Book For
Posted Date:
Students also viewed these algorithms questions
-
2. For the mechanical system shown below, find the transfer function, G(s)=X, 1N/m X (2) 1N/m 0000 0000 FLE 1 N-s/m 1kg 1kg
-
Explain life - cycle analysis and how organizations are using it to pay more attention to the total environmental impact.
-
Let A, B be sets. Define: (a) the Cartesian product (A B) (b) the set of relations R between A and B (c) the identity relation A on the set A [3 marks] Suppose S, T are relations between A and B, and...
-
Bhushan Building Supplies entered into the following transactions. Prepare journal entries under the perpetual inventory system. June 1 Purchased merchandise on account from Brij Builders Materials,...
-
Create a professional presentation to serve as an executive overview detailing all the aspects of the plan. Remember that your presentation is the first item the team will look at, so try to capture...
-
Find the Norton equivalent at terminals a-b of the circuit in Fig. 4.119? 0.25, 6 2 18 V
-
Indicate whether the following events might cause stocks in general to change price, and whether they might cause Big Widget Corp.'s stock to change price. A. B. C. D. PE E. The government announces...
-
What actions could have been taken to improve the functioning of the HP board?
-
Exercise 12-06 The current sections of Martinez Corp.s balance sheets at December 31, 2021 and 2022, are presented here. Martinez Corp.s net income for 2022 was $241,300. Depreciation expense was...
-
Coca Cola (KO) price is $61/share. The company is expected to pay dividend of $1.7/share next year. (In reality, dividends are paid quarterly. In this question we will assume for simplicity that all...
-
Applying the Accounting Equation and Computing Financing Proportions Use the accounting equation to compute the missing financial amounts. ($ millions) Hewlett-Packard General Mills Target...
-
In developing rates, premium data must be adjusted for current rate level. Explain why this must be done. In developing rates, the loss data must be adjusted for future development. Explain why this...
-
Assume a partnership worth $1,600,000 has 3 partners. Partner A owns 51%, partner B owns 39%, and partner C owns 10%. What is the proper amount of cross-purchase insurance that each partner will...
-
Race matters profoundly for health because Black and White people are not treated equally. As Williams shares with us that, "Every seven minutes, a black person dies prematurely in the United States....
-
dy dz ns Suppose xy= -2 and == =-2. Find when a -4. dt dt dx dt
-
On December 3 1 , 2 0 2 3 , Berclair Incorporated had 5 4 0 million shares of common stock and 2 1 million shares of 9 % , $ 1 0 0 par value cumulative preferred stock issued and outstanding. On...
-
Problem 4-17 (Algo) Cost Flows [LO 4-1] Lubricants, Incorporated, produces a special kind of grease that is widely used by race car drivers. The grease is produced in two processing...
-
When the concentration of a strong acid is not substantially higher than 1.0 10-7 M, the ionization of water must be taken into account in the calculation of the solution's pH. (a) Derive an...
-
The thickness, in mm, of metal washers is measured on samples of size 5. The following table presents the means, ranges, and standard deviations for 20 consecutive samples. The means are = 2.505, =...
-
The lens equation says that if an object is placed at a distance p from a lens, and an image is formed at a distance q from the lens, then the focal length f satisfies the equation 1/ f = 1/p +1/q....
-
For the lettuce yield data, (page 494) it is thought that the yields from fertilizer A might have a larger variance than the yields from fertilizer B. a. Compute the sample variances s2A and s2B of...
-
Brandon Company produces and sells a product that has variable costs of $9 per unit and fixed costs of $110,000 per year. 1. Compute the unit cost at a production and sales level of 10,000 units per...
-
Evaluating performance, decision by decision, is costly. Aggregate measures, like the income statement, are frequently used. How might the wide use of income statements affect managers decisions...
-
An administrator at Riverview Hospital is considering how to use some space made available when the outpatient clinic moved to a new building. She has narrowed her choices as follows: a. Use the...
Study smarter with the SolutionInn App