Question: Building an Area Calculator: Write a program in C ++ that stores 3 integers: side (of a square), length and width (of a rectangle). The

Building an Area Calculator:

Write a program in C ++ that stores 3 integers: side (of a square), length and width (of a rectangle). The values for these integers are entered by the user. Make sure to include the following:

Functions with int as a return datatype:

- A function called calcArea() that accepts an integer representing the length of the side of a square as a parameter and calculates, then returns the area of that square. This function should not have any print statements.

In your main() function print the area returned from this function without storing the returned value in a variable.

Functions with bool as a return datatype:

- A function called isLargeArea() that accepts an integer representing the length of the side of a square as a parameter and calculates the area of that square. This function returns true if the calculated area is greater than 20. The function should not have any print statements.

In your main() function print the statement The area is larger than 20 if the value returned by the function is true, or The area is less than or equal 20 otherwise. Do not use (== true) in your if statement.

Overloaded functions:

- A function called calcArea() that finds the area of a rectangle where the length and width entered by the user are passed to the function. This function should return an integer representing the calculated area.

In your main() function print the area returned from this function after storing the returned value in a local variable.

Reference variables:

- A function called calcAreaRef() that finds the area of a square. This function should not return any value. Without using global variables, the main function should still have access to the calculated area.

In your main() function print the area calculated in this function.

Static variables:

- A function called calcArea() that finds the area of a rectangle. This function should return an integer representing the calculated area. It should not accept any parameters.

In your main() function, call the function 5 times through a for loop to print the area of the 5 rectangles. It should find the area of 5 rectangles whose lengths and widths are multiples of 6 and 4 respectively.

(underscores " _ " are being used for spacing in the output, do not include them in the code)

The output should look like this:

Rectangle _ _ _ _ _ _ Area

_ _ 1 _ _ _ _ _ _ _ _ _ 24

_ _ 2 _ _ _ _ _ _ _ _ _ 96

_ _ 3 _ _ _ _ _ _ _ _ _ 216

_ _ 4 _ _ _ _ _ _ _ _ _ 384

_ _ 5 _ _ _ _ _ _ _ _ _ 600

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!