//Natalie Zarate Chapter 5, P. 220, #4
/*******************************************************************************
*
* COMPUTE AND COMPARE
* _____________________________________________________________________________
* This program accepts as input the length and width of two rectangles then
* computes the area of the rectangles which are then compared to determine
* whether their areas are equal to eachother or if one's area is greather than
* the area of the other.
* depending on how many seconds the user inputs.
* _____________________________________________________________________________
* INPUT
* width_1 : width of the first rectangle
* length_1 : length of the first rectangle
* width_2 : width of the second rectangle
* length_2 : length of the second rectangle
*
* OUTPUT
* area_1 : area of the first rectangle
* area_2 : area of the second rectangle
* Comparision of both areas
*
******************************************************************************/
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
float width_1; // INPUT - width of the first rectangle
float width_2; // INPUT - width of the second rectangle
float length_1; // INPUT - length of the first rectangle
float length_2; // INPUT - length of the second rectangle
float area_1; // OUTPUT - area of the first rectangle
float area_2; // OUTPUT - area of the second rectangle
// Prompt user for 1st rectangle's width and length
cout << "Enter width of the first rectangle:" << endl;
cin >> width_1;
cout << "Enter length of the first rectangle:" << endl;
cin >> length_1;
// Prompt user for the 2nd rectangle's width and length
cout << "Enter width of the second rectangle:" << endl;
cin >> width_2;
cout << "Enter length of the second rectangle:" << endl;
cin >> length_2;
// Calculate area of the rectangles
area_1 = width_1 * length_1;
area_2 = width_2 * length_2;
// Display calculations
cout << endl;
cout << "The area of the first rectangle is " << area_1 << "." << endl;
cout << "The area of the second rectangle is " << area_2 << "." << endl;
// Display comparision
if (area_1 > area_2)
{
cout << "The area of the first rectangle is greater than the second";
cout << " rectangle's area." << endl;
}
if (area_2 > area_1)
{
cout << "The area of the second rectangle is greater than the first";
cout << " rectangle's area." << endl;
}
if (area_1 == area_2)
cout << "The area of the rectangles are equal.";
return 0;
}