2 class lineType | Instructions 3 { 4 public: The equation of a line in standard form is ax void setline(double a - 0, double b - 0, double c - e); + by = c, wherein //Function to set the line. both a and b 8 void equation() const; cannot be zero, and 9 a, b, and c are real numbers. If b=0, 10 double getXCoefficient() const; double getYCoefficient() const; double getcOnstantTerm() const; 11 then -a/b is the slope 12 13 of the line. If a = 0, void setXCoefficient(double coeff); void setYCoefficient(double coeff); 14 then it is a horizontal 15 line, and if b = 0, then 16 void setConstantTerm(double c); it is a vertical line. The slope of a vertical line is undefined. Two 17 18 double slope() const; 19 //Return the slope. This function does not check if the lines are parallel if they have the same slope or both are 20 //line is vartical. Because the slope of a vertical line 21 //is undefined, before calling this function vertical lines. Two check if the lines are 22 //line is nonvertial. 23 perpendicular if 24 bool verticalLine() const; either one of the lines 25 bool horizontalline() const; is horizontal and the 26 other is vertical or the bool equallines(lineType otherLine) const; 27 product of their slopes is -1. Design 28 //Returns true of both lines are the same. 29 the class lineType 30 bool parallel(lineType otherLine) const; 31 //Function to determine if this line is parallel to store a line. To to otherLine. store a line, you need 32 to store the values of 33 bool perpendicular(lineType otherLine) const; a (coefficient of x), //Function to determine if this line is 34 perperdicular to otherLine. b (coefficient of y), and c. Your class 35 void pointofIntersection(lineType otherLine); //If lines intersect, then this function finds the point 36 must contain the 37 following operations: 38 //of intersection. • If a line is 39 40 lineType (double a - 0, double b = 0, double c - 0); nonvertical, then 41 //Constructor determine its 42 slope. 43 private: 44 double xCoeff; • Determine if two double yCoeff; 45 lines are equal. 46 double constTerm; 47 bool hasslope; (Two lines a,x + 48 }; b,y = c, and a,x + 49 bay = C2 are equal if either a, = a, b, = b2, and c, = C2, or a, = kaz, b, = kb, and c, = kc2, and for some real number k .) Determine if two lines are parallel. • Determine if two lines are perpendicular.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
**Instructions**

The equation of a line in standard form is \( ax + by = c \), where both \( a \) and \( b \) cannot be zero, and \( a \), \( b \), and \( c \) are real numbers. If \( b \neq 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 are vertical lines. Two lines are perpendicular if either one of the lines is horizontal and the other 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 \) (coefficient of \( x \)), \( b \) (coefficient of \( y \)), and \( c \). Your class must contain the following operations:

- If a line is nonvertical, then determine its slope.
- Determine if two lines are equal. (Two lines \( a_1x + b_1y = 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 \), and for some real number \( k \).)
- Determine if two lines are parallel.
- Determine if two lines are perpendicular.
- If two lines are not parallel, determine the point of intersection.

**Code Explanation**

```cpp
class lineType 
{
public:
    void setLine(double a = 0, double b = 0, double c = 0);
    // Function to set the line.

    void equation() const;

    double getXCoefficient() const;
    double getYCoefficient() const;
    double getConstantTerm() const;

    void setXCoefficient(double coeff);
    void setYCoefficient(double coeff);
    void setConstantTerm(double c);

    double slope() const;
    // Return the slope. This function does not check
Transcribed Image Text:**Instructions** The equation of a line in standard form is \( ax + by = c \), where both \( a \) and \( b \) cannot be zero, and \( a \), \( b \), and \( c \) are real numbers. If \( b \neq 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 are vertical lines. Two lines are perpendicular if either one of the lines is horizontal and the other 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 \) (coefficient of \( x \)), \( b \) (coefficient of \( y \)), and \( c \). Your class must contain the following operations: - If a line is nonvertical, then determine its slope. - Determine if two lines are equal. (Two lines \( a_1x + b_1y = 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 \), and for some real number \( k \).) - Determine if two lines are parallel. - Determine if two lines are perpendicular. - If two lines are not parallel, determine the point of intersection. **Code Explanation** ```cpp class lineType { public: void setLine(double a = 0, double b = 0, double c = 0); // Function to set the line. void equation() const; double getXCoefficient() const; double getYCoefficient() const; double getConstantTerm() const; void setXCoefficient(double coeff); void setYCoefficient(double coeff); void setConstantTerm(double c); double slope() const; // Return the slope. This function does not check
To store the values of \( a \) (coefficient of \( x \)), \( b \) (coefficient of \( y \)), and \( c \), your class must contain the following operations:

- **Determine the Slope**: If a line is non-vertical, calculate its slope.
  
- **Equality of Lines**: Check if two lines are equal. Two lines \( a_1x + b_1y = 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 = k a_2 \), \( b_1 = k b_2 \), and \( c_1 = k c_2 \), for some real number \( k \).

- **Parallel Lines**: Determine if two lines are parallel.

- **Perpendicular Lines**: Determine if two lines are perpendicular.

- **Intersection Point**: If two lines are not parallel, calculate the point of intersection. The method should indicate one of three options:
  - The intersection point in the format: \( (x, y) \).
  - A message stating "Both lines are equal."
  - A message stating "Lines do not intersect."

Add appropriate constructors to initialize variables of `lineType`. Also, write a program to test your class.
Transcribed Image Text:To store the values of \( a \) (coefficient of \( x \)), \( b \) (coefficient of \( y \)), and \( c \), your class must contain the following operations: - **Determine the Slope**: If a line is non-vertical, calculate its slope. - **Equality of Lines**: Check if two lines are equal. Two lines \( a_1x + b_1y = 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 = k a_2 \), \( b_1 = k b_2 \), and \( c_1 = k c_2 \), for some real number \( k \). - **Parallel Lines**: Determine if two lines are parallel. - **Perpendicular Lines**: Determine if two lines are perpendicular. - **Intersection Point**: If two lines are not parallel, calculate the point of intersection. The method should indicate one of three options: - The intersection point in the format: \( (x, y) \). - A message stating "Both lines are equal." - A message stating "Lines do not intersect." Add appropriate constructors to initialize variables of `lineType`. Also, write a program to test your class.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Data members
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education