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

g. 10 QUESTION 7 3 poir The equation of a line in standard form is ax + by = c,

ID: 3869806 • Letter: G

Question

g. 10 QUESTION 7 3 poir The equation of a line in standard form is ax + by = c, wherein both a and b cannot be zero, and a, b, and c are real numbers. Ifb +0, thern -alis the slope of the line. If a = 0, then it is a horizontal line, and if b = 0, then it is a vertical line. The slope of a vertical line is undefined. Two lines are parallel if they have the same slope or both are vertical lines. Two lines are perpendicular if either one of the lines is horizon- tal and the other is vertical or the product of their slopes is -1. Design the class 1ineType to store a line. To store a line, you need to store the values of a (coefficient 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. =c, and Determine if two lines are equal. (Two lines aix + b a2x + b,y = c2 are equal if either al =a,, bl =b2, and q =Cz or ai = ka,, bi-kb2, and G = ka for some real number k.) Determine if two lines are parallel. Determine if two lines are perpendicular. If two lines are not parallel, then find the point of intersection. b. c d. Add appropriate constructors to initialize variables of 11neType. Also write a program to test your class. Attach File Browse My Computer Browse Content Collection Click Save and Submit to save and submit. Click Save All Answers to save all answers Save All Answers

Explanation / Answer

#include<iostream>

using namespace std;

class lineType {
    private:
      double a,b,c;
    public:
       lineType(double a1, double b1, double c1){
          a = a1;
          b = b1;
          c = c1;
       }
       double getA(){
           return a;
       }  
       double getB(){
           return b;
       }   
       double getC(){
           return c;
       }      
       double slope(){
           if (b != 0)
               return (-a/b);
           else
               return -1; // Vertical line
       }
       bool isParallel(lineType l){
         
          if ((a == l.getA() && b == l.getB()) || ((b == 0 && l.getB() == 0) || (a == 0 && l.getA() == 0)))
             return true;
          else
             return false;
       }
       bool isEqual(lineType l){
          if (a == l.getA() && b == l.getB() && c == l.getC())
             return true;
          else
             return false;
       }
       void intersection(lineType l){
          double x1, y1;
          double a1,b1,c1,a2,b2,c2;
          if (!isParallel(l)){
              a1 = a;
              b1 = b;
              c1 = c;
              a2 = l.getA();
              b2 = l.getB();
              c2 = l.getC();
              x1 = (b2*c1 - b1 *c2)/(b2 *a1 - b1*a2);
              y1 = (a2*c1-a1*c2)/(a2*b1 -a1*b2);
              cout << x1 << " " << y1 << endl;
          }
          else {
          }
       }
};

int main(){

   lineType l1(2,3,4);
   lineType l2(2,3,4);
   lineType l3(1,3,5);
   lineType l4(4,0,3);
   lineType l5(6,0,3);
   lineType l6(0,6,3);

   cout << l1.slope() << endl;
   cout << l1.isEqual(l2) << endl;
   cout << l4.isParallel(l5) << endl;
   l2.intersection(l3);  

  
}