//Amari Mosley CSC5 Chapter 6, P. 369, #2
//
/*****************************************************************
 *
 * Compute Rectangle Area
 * _______________________________________________________________
 * This program asks the user for the length and width of a
 * rectangle, then computes and displays its area.
 *
 * Computation is based on the formula:
 *   area = length * width
 * _______________________________________________________________
 * INPUT
 *   length : the rectangle's length
 *   width  : the rectangle's width
 *
 * OUTPUT
 *   area   : the rectangle's area
 *
 *****************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;

// Function prototypes
double getLength();
double getWidth();
double getArea(double length, double width);
void displayData(double length, double width, double area);

int main()
{
    double length;   // length of the rectangle
    double width;    // width of the rectangle
    double area;     // area of the rectangle

    // Get the rectangle's dimensions
    length = getLength();
    width = getWidth();

    // Calculate the area
    area = getArea(length, width);

    // Display the results
    displayData(length, width, area);

    return 0;
}


  //getLength
  //  Asks the user for the rectangle's length and returns it.

double getLength()
{
    double length;

    cout << "Enter the rectangle's length: ";
    cin >> length;

    return length;
}


 // getWidth
 //   Asks the user for the rectangle's width and returns it.

double getWidth()
{
    double width;

    cout << "Enter the rectangle's width: ";
    cin >> width;

    return width;
}


 // getArea
 //   Receives the length and width and returns the area.

double getArea(double length, double width)
{
    return length * width;
}


 // displayData
 //   Receives the length, width, and area and displays them.

void displayData(double length, double width, double area)
{
    cout << fixed << setprecision(2);
    cout << "\nRectangle Data" << endl;
    cout << "Length: " << length << endl;
    cout << "Width:  " << width << endl;
    cout << "Area:   " << area << endl;
}