//Isabel Tejeda CSC5 Chapter 4, page 220, #4
//
/*******************************************************************************
*
* CATERGORIZE AREA OF RECTANGLE
* _____________________________________________________________________________
* This program will ask for the input of length and width for two rectangles. It
* will then calculate the area of both rectangles and determine which of the two
* rectangeles has the greater area, or if the areas are the same.
*
* Computation is based on the formula:
* area1 = length1 * width1
* area2 = length2 * width2
* _____________________________________________________________________________
* INPUT
* length1 : The legnth of the first rectangle
* width1 : The width of the first rectangle
* length2 : The length of the second rectangle
* width2 : The width of the second rectangle
*
* OUTPUT
* relationOfAreas : The relation between the two areas of the rectangles
* (Which one is greater than the other or if they are
* equal)
*
******************************************************************************/
#include
#include
using namespace std;
int main()
{
float length1; //The length of the first rectangle
float width1; //The width of the first rectangle
float length2; //The length of the second rectangle
float width2; //The width of the second rectangle
float area1; //The area of the first rectangle
float area2; //The area of the second rectangle
string relationOfAreas; /* The relation between the two areas of the rectangles
(Which one of is greater than the other or if they are equal)*/
//
// Initialize Program Varaibles
cout << "Enter the length of the first rectangle: "<< endl;
cin >> length1;
cout << "Enter the width of the first retangle: " << endl;
cin >> width1;
cout << "Enter the length of the second rectangle: " << endl;
cin >> length2;
cout << "Enter the width of the second rectangle: " << endl;
cin >> width2;
//
// Calculate the Area of the Two Rectangles
area1 = length1 * width1;
area2 = length2 * width2;
//
// Finding the relation between the two area rectangles and Output Result
if (area1 < area2)
{
relationOfAreas = "The second rectangle has the greater area.";
cout << relationOfAreas;
}
else if (area1 == area2)
{
relationOfAreas = "The areas of the rectangles are the same.";
cout << relationOfAreas;
}
else
{
relationOfAreas = "The first rectangle has the greater area.";
cout << relationOfAreas;
}
return 0;
}