Hi, I need the answer to this question using the C++ programming language. Thank you. Question: Rectangle Area—Complete the Program If you have downloaded the source code, you will find a partially written program named Pr6-13.cpp in the Chapter 6 folder. Your job is to complete the program. When it is complete, the program will ask the user to enter the width and length of a rectangle and then display the rectangle’s area. The program calls the following functions, which have not been written: getLength – This function should ask the user to enter the rectangle’s length and then return that value as a double. getWidth – This function should ask the user to enter the rectangle’s width and then return that value as a double. getArea – This function should accept the rectangle’s length and width as arguments and return the rectangle’s area. The area is calculated by multiplying the length by the width. displayData – This function should accept the rectangle’s length, width, and area as arguments and display them in an appropriate message on the screen.
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
Hi, I need the answer to this question using the C++
Question:
Rectangle Area—Complete the Program
If you have downloaded the source code, you will find a partially written program named Pr6-13.cpp in the Chapter 6 folder. Your job is to complete the program. When it is complete, the program will ask the user to enter the width and length of a rectangle and then display the rectangle’s area. The program calls the following functions, which have not been written:
-
getLength – This function should ask the user to enter the rectangle’s length and then return that value as a double.
-
getWidth – This function should ask the user to enter the rectangle’s width and then return that value as a double.
-
getArea – This function should accept the rectangle’s length and width as arguments and return the rectangle’s area. The area is calculated by multiplying the length by the width.
-
displayData – This function should accept the rectangle’s length, width, and area as arguments and display them in an appropriate message on the screen.
------------------------------------------------------------------------
Program 6-13
// This program demonstrates two value-returning functions.
// The square function is called in a mathematical statement.
#include <iostream>
#include <iomanip>
using namespace std;
//Function prototypes
double getRadius();
double square(double);
int main()
{
const double PI = 3.14159; // Constant for pi
double radius; // To hold the circle's radius
double area; // To hold the circle's area
// Set the numeric output formatting.
cout << fixed << showpoint << setprecision(2);
// Get the radius of the circle.
cout << "This program calculates the area of ";
cout << "a circle.\n";
radius = getRadius();
// Calculate the area of the circle.
area = PI * square(radius);
// Display the area.
cout << "The area is " << area << endl;
return 0;
}
//******************************************************
// Definition of function getRadius. *
// This function asks the user to enter the radius of *
// the circle and then returns that number as a double.*
//******************************************************
double getRadius()
{
double rad;
cout << "Enter the radius of the circle: ";
cin >> rad;
return rad;
}
//******************************************************
// Definition of function square. *
// This function accepts a double argument and returns *
// the square of the argument as a double. *
//******************************************************
double square(double number)
{
return number * number;
}
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images