Question: (How to solve this one for the same problem. Assignment #6 - User-defined functions square geometry) #After requesting the user enter the x, y coordinates
(How to solve this one for the same problem. Assignment #6 - User-defined functions square geometry)
#After requesting the user enter the x, y coordinates for the object, prompt the user for a 3rd point. your program will then determine if the third point is inside the object. note: to be considered inside, the point must be fully inside the object, and not on the line.
#include
using namespace std;
int calcLength(int pt1coord, int pt2coord); int area(int length, int width); bool isSquare(int length, int width);
int calcLength(int pt1coord, int pt2coord) {
int len = 0;
cout << "First coord = " << pt1coord << endl; cout << "Second coord = " << pt2coord << endl;
len = pt2coord - pt1coord;
cout << "Length of sides: " << abs(len) << endl;
return len; }
int area(int len, int width)
{ return len*width; } bool issquare(int len, int width) { if(len == width) return true; else return false; }
int main() { int x1,x2,y1,y2; int side1, side2;
cout << "Enter x1 and y1: " << endl; cin >> x1>>y1; cout << endl;
cout << "Enter x2 and y2: " <
int length = calcLength(x1, x2); int width = calcLength(y1, y2); cout <<"Length: " << abs (length) << endl; cout <<"Width: " << abs (width) << endl;
int area1 = area(length, width); cout<< "Area: " << abs (area1)<< endl;
if(issquare(length, width)) cout << "The Figure is Square."; else cout << "The Figure is Rectangle.";
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
