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

For this project you will be building a new type lineType, as defined in Chapter

ID: 3630463 • Letter: F

Question

For this project you will be building a new type lineType, as defined in Chapter 12, Programming Exercise # 12. Program this with a header file, an implementation file and a .cpp file to test your lineType.
If you do not have the book available, the exercise can be found from google books by following this link (Right click the link and open in a new window): http://books.google.com/books?id=jvBslGr-sxEC&pg=PA721&lpg=PA721&dq=line+in+standard+form+c%2B%2B+class+linetype&source=bl&ots=96we9qIWEi&sig=Tt5638eocsYi2dVuwzEMFYmNSNE&hl=en&ei=MleLTuqgFuLI0AG1_KjHBA&sa=X&oi=book_result&ct=result&resnum=1&ved=0CBoQ6AEwAA#v=onepage&q&f=false


Please note: It will take you some time to figure out how to program the intersection of two lines. Do everything else in Exercise 12 first. You will want to figure it out by hand on two sample lines (say a1x + b1y = c1, and a2x + b2y = c2) to get the formulas for the coordinates of the intersecting points. You can use to help with the math. This site changes the line formula to the form y = mx + b where m is the slope and b is the y intercept to do the math, but you can do it either way.
2. To illustrate information hiding and ADTs this part of the project should not be done until Part 1 is totally complete. You will be given a data file with a few sets of four lines. [click here for datafile]:

10 2 620 4 -83 -1 -4-14 2 0
-4 2 -2-.5 .25 -.756 3 2710 5 2515 -3 -910 -2 31.2 1 31 5 -15.85


Each of those sets of lines (if graphed in a Cartesian plane) create a quadrilateral [4 sided shape]. (To make this program easier, the first two lines in the set will be opposite each other in the quadrilateral, and the second two lines in the set will be opposite each other in the quadrilateral.) Write a program that uses your header file and class that was defined for Part 1 of this assignment to determine if each quadrilateral in the data file is a parallelogram, trapezoid or rectangl

Explanation / Answer

//Header file section

#include<iostream>

using namespace std;

//Class declaration

class Line

{

private: double a;

          double b;

          double c;

public://Constructor

        Line(double x,double y,double z)

        {

             a=x;

             b=y;

             c=z;

        }

        //Member functions

        double getA();

        double getB();

        double getC();

        double slope();

     void NonVertical()

     {

          if ( b!=0 )

              cout<<"Slope is:"<< slope()<<endl;

          else

              cout << "Vertical" << endl;

     }

      bool isEqual( Line L2)

     {

          if ( (a==L2.getA()&& b==L2.getB()&&

                    c==L2.getC() )

                 ||(a/L2.getA()==b/L2.getB()==c/L2.getC()))

              return true;

          else

              return false;

     }

    

      bool isParallel(Line& L2,double sl)const

      {

         

          if((sl== L2.slope())

              ||(b==0 && L2.getA()==0))

              return true;

          else

              return false;          

     }

     void isPerpendicular(Line& L2,double sl)const

     {  

         

          if ( ( ( a == 0 && L2.getB() == 0 )

                        || ( L2.getA() == 0 && b == 0 ) )

                        || ( L2.slope()* sl == -1 ) )

              cout<<"Two Lines are Perpendicular"<<endl;

          else

              cout<<"Not Perpendicular"<<endl;

     }

     void doubleersection(Line& L2)const

     {

          double x,y;

         x=((b*L2.getC())-(L2.getB()*c))/

                         ((a*L2.getB())-(L2.getA()*b));

          y=((L2.getA()*c)-(a*L2.getC()))/

                           ((a*L2.getB())-(L2.getA()*b));

          cout<<"doubleersection podouble: ("

                                   <<x<<", "<<y<<")"<<endl;

     }

};

double Line::getA()

        {

             return a;

        }

double Line::getB()

{

   return b;

}

double Line:: getC()

{

return c;

}

double Line::slope()

{

return -a/b;

void main()

{  

     //CREATING LINE 1 OBJECT

     Line L1(3,3,5);

     cout<<"Line 1:"<<endl;

     L1.NonVertical();

    

     //CREATING LINE 2 OBJECT

     cout<<"Line 2"<<endl;

     Line L2(2,1,5);

     L2.NonVertical();

    

     //CHECK FOR PARALLEL LINES

     if(L1.isParallel(L2,L1.slope()))

          cout<<"Two lines are parallel "<< endl;

     else

          cout<<"Not Parallel"<<endl;

    

    //fUNCTION CALL TO CHECK FOR PERPENDICULAR LINES

     L1.isPerpendicular(L2,L1.slope());

    

     //To find doubleersction podouble

     if(!L1.isParallel(L2,L1.slope()))

          L1.doubleersection(L2);

         //PAUSE SYSTEM FOR A WHILE

          system("pause");

}//end 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