// Cenyao Huang CS1A Homework 4, p. 220, #4
/************************************************************************************
* DETERMINE WHICH RECTANGLE AREA IS GREATER
*
* This program determines which of two triangle areas is greater after their length
* and widths are inputted.
*
* This program will use the formula:
* Area = length * width
*
* Input
* length1 : the value of the length of the first rectangle
* width1 : the value of the width of the first rectangle
* length2: the value of the length of the second rectangle
* width2 : the value of the width of the second rectangle
* Area1 : the value of the area of the first rectangle
* Area2 : the value of the area of the second rectangle
*
* Output
* A message that shows which rectangle is greater, or if the input is invalid
*
*
************************************************************************************/
#include <iostream>
using namespace std;
int main() {
double length1, width1, length2, width2, Area1, Area2; // variable assignment
// Ask and display length, width, and area of first rectangle
cout << "Please enter the length and width the first rectangle: ";
cin >> length1 >> width1;
cout << length1 << " " << width1 << endl;
Area1 = length1 * width1;
cout << "The area of the first rectangle is: " << Area1 << endl << endl;
// Ask and display length, width, and area of second triangle
cout << "Please enter the length and width of the second triangle: ";
cin >> length2 >> width2;
cout << length2 << " " << width2 << endl;
Area2 = length2 * width2;
cout << "The area of the second rectangle is: " << Area2 << endl << endl;
// determine and display the greater area
if (Area1 > Area2)
cout << "The first rectangle has a greater area.";
else if (Area2 > Area1)
cout << "The second rectangle has a greater area.";
else
cout << "Invalid input. Please try again.";
return 0;
}