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.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education