The equation of a line in standard form is ax + by = c , wherein both aand b cannot be zero, and a, b, 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 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₁x + b₁y = c₁ and a₂x + b₂y = c₂ are equal if either a₁ = a₂, b₁ = b₂, and c₁ = c₂, or a₁ = ka₂, b₁ = kb₂ and c₁ = kc₂, and for some real number k.) Determine if two lines are parallel. Determine if two lines are perpendicular. If two lines are not parallel, then print the point of intersection. The intersection method should indicate one of three options: The intersection point in the format: (x, y) . A message indicating Both lines are equal. A message indicating the Lines do not inters

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

The equation of a line in standard form is ax + by = c , wherein both aand b cannot be zero, and a, b, 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 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₁x + b₁y = c₁ and a₂x + b₂y = c₂ are equal if either a₁ = a₂, b₁ = b₂, and c₁ = c₂, or a₁ = ka₂, b₁ = kb₂ and c₁ = kc₂, and for some real number k.)
  • Determine if two lines are parallel.
  • Determine if two lines are perpendicular.
  • If two lines are not parallel, then print the point of intersection. The intersection method should indicate one of three options: The intersection point in the format: (x, y) . A message indicating Both lines are equal. A message indicating the Lines do not intersect.

Add appropriate constructors to initialize variables of lineType. Also, write a program to test your class.

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,x +
b,y = c, and a,x +
bzy = C2 are equal
if either a, = a2, 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.
• If two lines are not
parallel, then print
the point of
intersection. The
intersection
method should
indicate one of
three options: The
intersection point
in the format: (x,
y) . A message
indicating Both
lines are equal. A
message
indicating the
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: • If a line is nonvertical, then determine its slope. • Determine if two lines are equal. (Two lines a,x + b,y = c, and a,x + bzy = C2 are equal if either a, = a2, 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. • If two lines are not parallel, then print the point of intersection. The intersection method should indicate one of three options: The intersection point in the format: (x, y) . A message indicating Both lines are equal. A message indicating the Lines do not intersect. Add appropriate constructors to initialize variables of lineType . Also, write a program to test your class .
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, doublec =
e);
+ by = c, wherein
both a and b
//Function to set the line.
7
8
void equation() const;
cannot be zero, and
9
a, b, and c are
double getXCoefficient() const;
10
real numbers. If b#0,
double getYCoefficient() const;
11
then -a/b is the slope
double getconstantTerm() const;
12
13
of the line. If a = 0,
14
void setXCoefficient (double coeff);
then it is a horizontal
15
void setYCoefficient(double coeff);
line, and if b = 0, then
16
void setConstantTerm(double c);
it is a vertical line. The
17
slope of a vertical line
double slope() const;
18
is undefined. Two
lines are parallel if
19
//Return the slope. This function does not check
if the
20
//line is vartical. Because the slope of a
they have the same
vertical line
slope or both are
//is undefined, before calling this function
21
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
//Returns true of both lines are the same.
28
29
slopes is -1. Design
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),
b (coefficient of y),
and c. Your class
34
//Function to determine if this line is
perperdicular to otherLine.
35
36
void pointofIntersection(lineType otherLine);
must contain the
37
//If lines intersect, then this function finds
following operations:
the point
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.
double constTerm;
46
47
bool hasslope;
(Two lines a,x +
48 };
b,y = c, and azX +
49
bzy = C2 are equal
if either a, = a2, b,
= b2, and c, = C2, or
a, = kaz, b, = kb2
and c, = kc2, and
for some real
number k .)
• Determine if two
lines are parallel.
• Determine if two
lines are
perpendicular.
• If two lines are not
Transcribed Image Text: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, doublec = e); + by = c, wherein both a and b //Function to set the line. 7 8 void equation() const; cannot be zero, and 9 a, b, and c are double getXCoefficient() const; 10 real numbers. If b#0, double getYCoefficient() const; 11 then -a/b is the slope double getconstantTerm() const; 12 13 of the line. If a = 0, 14 void setXCoefficient (double coeff); then it is a horizontal 15 void setYCoefficient(double coeff); line, and if b = 0, then 16 void setConstantTerm(double c); it is a vertical line. The 17 slope of a vertical line double slope() const; 18 is undefined. Two lines are parallel if 19 //Return the slope. This function does not check if the 20 //line is vartical. Because the slope of a they have the same vertical line slope or both are //is undefined, before calling this function 21 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 //Returns true of both lines are the same. 28 29 slopes is -1. Design 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), b (coefficient of y), and c. Your class 34 //Function to determine if this line is perperdicular to otherLine. 35 36 void pointofIntersection(lineType otherLine); must contain the 37 //If lines intersect, then this function finds following operations: the point 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. double constTerm; 46 47 bool hasslope; (Two lines a,x + 48 }; b,y = c, and azX + 49 bzy = C2 are equal if either a, = a2, b, = b2, and c, = C2, or a, = kaz, b, = kb2 and c, = kc2, and for some real number k .) • Determine if two lines are parallel. • Determine if two lines are perpendicular. • If two lines are not
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
Table
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