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.

Programming with Microsoft Visual Basic 2017
8th Edition
ISBN:9781337102124
Author:Diane Zak
Publisher:Diane Zak
Chapter7: String Manipulation
Section: Chapter Questions
Problem 6E
icon
Related questions
Question

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.

 

------------------------------------------------------------------------

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;

}

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Programming with Microsoft Visual Basic 2017
Programming with Microsoft Visual Basic 2017
Computer Science
ISBN:
9781337102124
Author:
Diane Zak
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781305480537
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT