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

The equation of a line in standard form is ax + by = c, wherein both a and b can

ID: 3765733 • Letter: T

Question

The equation of a line in standard form is ax + by = c, wherein both a and b cannot he zero, and a. h. and c are real numbers. If b = 0, then -a/b is 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 arc vertical lines. Two lines are perpendicular if either one of the lines is horizontal and the other is vertical or die product of their slopes is -1. Design the class linsType 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: If a line is non vertical, then determine its slope. Determine if two lines arc equal. (Two lines a_1 x + b_1 y = c_1 and a_2x + b_2y = c_2 are equal if either a_1 = a_2, b_1 = b_2. and c_1 = c_2 or a_1 = ka_2, b_1 = kb_2, and c_1 = kc_2 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. Add appropriate constructors to initialize variables of lineType. Also write a program to test your class. Point at which two Ines intersect.

Explanation / Answer

#include <iostream.h>   // input output stream header file
#include <stdio.h>   // standard input output header file
#include <stdlib.h>     // standard library header file
//#include <string.h>   // header file with string function
#include <conio.h>   // console input output header file
// line program
int isVert, isHoriz, isParl, isPerpd; // 1 = true, 0 = false, vertical , horizontal, parallel, perpendicular
class lineType   {
   // declare member variables
     public:
   int a,b,c,k; // k = real num ; for a line of the form ax+by=c
   void funcIsVertical()   { // to find whether a line is vertical or not
  
       isVert = 1;
  
       isVert = 0;


   } // end func funcIsVertical
   // constructor function to initialize memeber variables
   lineType(int a1, int b1, int c1, int k1) {
       a = a1; b = b1; c = c1;   // simply assign parameter values to the member values
       k = k1;
   } // end constr func
   // declare and define member functions
   void funcIsHorizontal()   { // to find whether a line is Horizontal or not
  
       isHoriz = 1;

  
       isHoriz = 0;


   } // end func funcIsHorizontal

   void funcIsParallel()   { // find is the lines are parallel or not
  

       isParl = 1;

       isParl = 0;

   } // end function funcIsParallel

   void funcIsPerpendicular()   { // find is the lines are Perpendicular or not
  
       isPerpd = 1;

       isPerpd = 0;

   } // end function funcIsPerpendicular


} ; // end class lineType


int main()   // start main
{
clrscr();
cout << " Enter values of a,b, c, for line 1: ";
int a1,b1,c1,a2, b2, c2, k;
cin >> a1; cin >> b1; cin >> c1;
cout << " Enter values of a,b, c, for line 2: ";
cin >> a2; cin >> b2; cin >> c2;
cout << " Enter value of k: ";
cin >> k;
lineType ln1(a1,b1,c1,k);
lineType ln2(a2,b2,c2,k);

if ( (a1==a2) && (b1 == b2) && (c1 == c2) ) cout << " The lines are equal.";
if ( (a1==k*a2) && (b1 == k*b2) && (c1 == k*c2) ) cout << " The lines are equal.";
float slope1, slope2;
if (b1 >0 ) slope1 = -1 * a1 / b1;
if (b2 >0 ) slope2 = -1 * a2 / b2;

if (slope1 == slope2) cout << " The lines are parallel ";
if (slope1 * slope2 == -1 ) cout << " The lines are perpendicular ";

//lineType(a1,b1,c1,k);

return 0; // exit
} // end of main()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote