Hello all I know you will see my question and say its a simple fix but this is all new to me and I did some research but its not sinking in. The problem is:
calculate the area of a rectangle using functions.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 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.
So I came ups with this but am getting errors
// Chapter 6, Programming Challenge 2
#include <iostream>
using namespace std;
// Write the prototypes for the getLength,
// getWidth, getArea, and displayData
// functions here.
double getLength();
double getWidth();
double getArea(double length, double width);
void displayData(double length, double width, double area);
int main()
{
double length, // The rectangle's length
width, // The rectangle's width
area; // The rectangle's area
// Get the rectangle's length.
length = getLength();
{
cout << "Enter length:";
cin >> length;
return length;
}
// Get the rectangle's width.
width = getWidth();
{
cout << "Enter width:";
cin >> width;
return width;
}
// Get the rectangle's area.
double area = getArea(length, width);
{
area = length * width;
return area;
}
// Display the rectangle's data.
void displayData(double length,double width,double area);
{
cout << "The length is:" << length<< endl;
cout << "The width is:" << width << endl;
cout <<"Total area is:" << area <<endl;
return 0;
}
//***************************************************
// You must write the getLength, getWidth, getArea, *
// and displayData functions. *
//***************************************************