//Jacob Silvestre CSC5 Chapter 4, P. 220, #4
//
/************************************************************************************
*
* COMPARE RECTANGLE AREAS
*____________________________________________________________________________________
* This program asks the user to enter the length and width of two rectangles. The
* program calculates the area of each rectangle and determines which rectangle has
* the larger area, or if both rectangles have the same area.
*
* Rectangle Area Formula:
* Area = Length x Width
*____________________________________________________________________________________
* INPUT
* length1 : Length of Rectangle 1
* width1 : Width of Rectangle 1
* length2 : Length of Rectangle 2
* width2 : Width of Rectangle 2
*
* OUTPUT
* area1 : Area of Rectangle 1
* area2 : Area of Rectangle 2
* Displays which rectangle has the greater area
*
**************************************************************************************/
#include <iostream>
using namespace std;
int main()
{
double length1; // INPUT - Length of Rectangle 1
double width1; // INPUT - Width of Rectangle 1
double length2; // INPUT - Length of Rectangle 2
double width2; // INPUT - Width of Rectangle 2
double area1; // OUTPUT - Area of Rectangle 1
double area2; // OUTPUT - Area of Rectangle 2
//
// Input Rectangle 1 Information
//
cout << "Enter the length of Rectangle 1: ";
cin >> length1;
cout << "Enter the width of Rectangle 1: ";
cin >> width1;
//
// Input Rectangle 2 Information
//
cout << "Enter the length of Rectangle 2: ";
cin >> length2;
cout << "Enter the width of Rectangle 2: ";
cin >> width2;
//
// Calculate Areas
//
area1 = length1 * width1;
area2 = length2 * width2;
//
// Output Areas
//
cout << endl;
cout << "Rectangle 1 Area: " << area1 << endl;
cout << "Rectangle 2 Area: " << area2 << endl;
//
// Compare Rectangle Areas
//
if (area1 > area2)
{
cout << "Rectangle 1 has the greater area." << endl;
}
else if (area2 > area1)
{
cout << "Rectangle 2 has the greater area." << endl;
}
else
{
cout << "Both rectangles have the same area." << endl;
}
return 0;
}