Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I\'m struggling with the question below. I need to answer questions a-e in addit

ID: 3569207 • Letter: I

Question

I'm struggling with the question below. I need to answer questions a-e in addition to writing a test code that applies. any help would be appreciated.

The equation of a line in standard form is ax+by=c, where a and b cannot be zero, and a, b, and c are real numbers. If b is not equal to zero, then -a/b is the slope of the line. If a=0, then it is a horizontal line, and if b=0, ten it is a vertical line The slope of the vertical line is undefined. Two lines are parallel if they have the same slope or both are vertical lines. Two lines are perpendicular if one of the lines horizontal and another is vertical, or the product of their slopes is -1. Design the class lineType to store a line. To store a line, you need to store the values of a (coefficent of x) , b (coefficient of y) and c. Your class must contain the following operations:
a. If a line is nonvertical, then determine its slope.
b. determine if the two lines are equal (two lines a1x+b1y=c and a2x+b2y=c20 ae equal if either a1=a2, b1=b2, and c1=c2 or a1=ka2, b1=kb2, and c1=kc2 for some real number k.)
c. Determine if the two lines are parallel
d determine if the two lines are perpendicular.
e. If the two lines are not parallel, then find the point of intersection.

Explanation / Answer

#include<iostream>

using namespace std;

class LineType{
private :
int a;
int b;
int c;
public :
LineType (int x, int y, int z){
a = x;
b = y;
c = z;
}
void getSlope(){
if(b == 0){
cout << "Slope is 90 degree ";
}else{
double slope = -((double)a/b);
cout << "Slope is " << slope << " degree ";
}
}

int isEqual(LineType l1){
if((a%l1.a == 0 && b%l1.b == 0 && c%l1.c == 0) || (l1.a%a == 0 && l1.b%b == 0 && l1.c%c == 0)){
cout << "The two lines are equal ";
return 1;
}else{
cout << "The two lines are not equal ";
return 0;
}
}

int isParallel(LineType l1){
if(b == 0 && l1.b == 0){
cout << "Both Lines are parallel ";
return 1;
}else{
double slope1 = -(double)a/b;
double slope2 = -((double)l1.a/l1.b);
if(slope1 == slope2){
cout << "Bothe lines are parallel ";
return 1;
}else{
cout << "Both lines are not parallel ";
return 0;
}
}
}

int isPerpendicular(LineType l1){
if(b == 0 && l1.a == 0){
cout << "Both lines are perpendicular ";
return 1;
}else{
double slope1 = -(double)a/b;
double slope2 = -((double)l1.a/l1.b);
if(slope1*slope2 == -1){
cout << "Bothe lines are perpendicular ";
return 1;
}else{
cout << "Bothe lines are not perpendicular ";
return 0;
}
}
}

void pointOfIntersection(LineType l1){
if(!((*this).isParallel(l1))){
double slope1 = -(double)a/b;
double slope2 = -((double)l1.a/l1.b);

double intersect1 = -(double)c/b;
double intersect2 = -((double)l1.c/l1.b);

int x = (intersect2 - intersect1)/(slope1 - slope2);
int y = slope1*x + intersect1;

cout << "Point of intersection is ( " << x << " , " << y << " ) ";
}
}
};

int main(){
LineType l1(2, 3 , 4);
LineType l2(5, 7, 9);

l1.getSlope();
l2.getSlope();
l1.isEqual(l2);
l1.isParallel(l2);
l1.isPerpendicular(l2);
l1.pointOfIntersection(l2);

return 0;
}