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 #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: " <>x2>>y2; cout << endl;

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!