Hey guys, i was assigned to determine which area is larger depending on what the user inputs by using a if statement we just learned this in class and i have some confusion on why it cannot run. Would really appreciate it if someone can help me with this thanks!
// Application Name: Areas of a rectangle.
// Programmer: Juan Gutierrez
// Date: 11/1/2016
// Purpose: Determine which rectangle's area is bigger after the user inputs there sides.
#include <iostream>
usingnamespace std;
int main()
{
//Stating the int's both sides for both rectangles, and both of there areas.
double length1, length2, width1, width2, area1, area2;
//Asking the user for the sides of both rectangles.
cout << "Please input the length and width of the first rectangle:" << endl;
cin >> length1, width1;
cout << "Now input the length and width of the second rectangle:" << endl;
cin >> length2, width2;
//Using the equation to get the area of a rectangle.
area1 = length1 * width1;
area2 = length2 * width2;
//Stating that which area is larger or the same by using a if statement.
if (area1 > area2) {
cout << "The first rectangle has a greater area." << endl;
ifelse (area2 > area1)
cout << "The second rectangle has a greater area." << endl;
else
cout << "Both area's are equal." << endl;
}
return 0;
}
if (area1 > area2) {
cout << "The first rectangle has a greater area." << endl;
}
elseif(area2 > area1)
cout << "The second rectangle has a greater area." << endl;
else
cout << "Both area's are equal." << endl;