Equation Slope (-a / b) Is point (5, -2) on the line? 5x+ 4y - 17 - 0 -5/4--1.25 Yes, because 5(5) + 4(-2) + (-17) =0 -25x + 40y + 30 = 0 25 / 40 -0.625 No, because -25(5) + 40(-2) + 30#0 Assume that the following code segment appears in a class other than APLine. The code segment shows an example of using the APLine classt represent the two equations shown in the table. APLine linel - new APLine (5, 4, -17); double slopel - linel.getslope (); boolean onLinel - linel.isOnLine (5, -2); // true because 5(5) + 4(-2) + (-17)-0 // slopel is assigned -1.25 APLine line2 - new APLine (-25, 40, 30): double slope2 - line2.getslope (): boolean onlLine2 - line2.isOnLine (5, -2); // £false because -25(5) + 40(-2) + 30 # 0 // slope2 is assigned 0.625 Write the APLine class. Your implementation must include a constructor that has three integer parameters that represent a, b, and c, in that order. You may assume that the values of the parameters representing a and b are not zero. It must also include a method getSlope that calculates and returns the slope of the line, and a method isOnLine that returns true if the point represented by its two parameters (x and y, in that order) is on the APLine and returns false otherwise. Your class must produce the indicated results when invoked by the code segment given above. You may ignore any issues related to integer overflow.

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

Directions: SHOW ALL YOUR WORK. REMEMBER THAT PROGRAM SEGMENTS ARE TO BE WRITTEN IN JAVA.

Notes:

  • Assume that the classes listed in the Quick Reference found in the Appendix have been imported where appropriate.

  • Unless otherwise noted in the question, assume that parameters in method calls are not null and that methods are called only when their preconditions are satisfied.

  • In writing solutions for each question, you may use any of the accessible methods that are listed in classes defined in that question. Writing significant amounts of code that can be replaced by a call to one of these methods may not receive full credit.

An APLine is a line defined by the equation ax + by + c = 0 , where a is not equal to zero, b is not equal to zero, and a, b, and c are all integers. The slope of an APLine is defined to be the double value -a b/ . A point (represented by integers x and y) is on an APLine if the equation of the APLine is satisfied when those x and y values are substituted into the equation. That is, a point represented by x and y is on the line if ax + by + c is equal to 0. Examples of two APLine equations are shown in the following table.

 

Submit
Slope (-a / b)
Is point (5, -2) on the line?
Yes, because 5(5) + 4(-2) +(-17) = 0
Equation
5x + 4y - 17 = 0
-5/4 = -1.25
-25x + 40y + 30 = 0
25 / 40 = 0.625
No, because -25(5) + 40(-2) + 30 # 0
Assume that the following code segment appears in a class other than APLine. The code segment shows an example of using the APLine class to represent the two equations shown in the table.
APLine linel = new APLine (5, 4, -17);
double slopel = linel.getSlope ();
boolean onLinel = linel.isOnLine (5, -2); // true because 5(5) + 4(-2) + (-17) = 0
// slopel is assigned -1.25
APLine line2 = new APLine (-25, 40, 30);
double slope2 = line2.getSlope ();
boolean onLine2 = line2.isOnLine (5, -2); |/ false because -25(5) + 40(-2) + 30 # 0
// slope2 is assigned 0.625
Write the APLine class. Your implementation must include a constructor that has three integer parameters that represent a, b, and c, in that order. You may assume that the values of the
parameters representing a and b are not zero. It must also include a method getSlope that calculates and returns the slope of the line, and a method isOnLine that returns true if the point
represented by its two parameters (x and y, in that order) is on the APLine and returns false otherwise. Your class must produce the indicated results when invoked by the code segment given
above. You may ignore any issues related to integer overflow.
Transcribed Image Text:Submit Slope (-a / b) Is point (5, -2) on the line? Yes, because 5(5) + 4(-2) +(-17) = 0 Equation 5x + 4y - 17 = 0 -5/4 = -1.25 -25x + 40y + 30 = 0 25 / 40 = 0.625 No, because -25(5) + 40(-2) + 30 # 0 Assume that the following code segment appears in a class other than APLine. The code segment shows an example of using the APLine class to represent the two equations shown in the table. APLine linel = new APLine (5, 4, -17); double slopel = linel.getSlope (); boolean onLinel = linel.isOnLine (5, -2); // true because 5(5) + 4(-2) + (-17) = 0 // slopel is assigned -1.25 APLine line2 = new APLine (-25, 40, 30); double slope2 = line2.getSlope (); boolean onLine2 = line2.isOnLine (5, -2); |/ false because -25(5) + 40(-2) + 30 # 0 // slope2 is assigned 0.625 Write the APLine class. Your implementation must include a constructor that has three integer parameters that represent a, b, and c, in that order. You may assume that the values of the parameters representing a and b are not zero. It must also include a method getSlope that calculates and returns the slope of the line, and a method isOnLine that returns true if the point represented by its two parameters (x and y, in that order) is on the APLine and returns false otherwise. Your class must produce the indicated results when invoked by the code segment given above. You may ignore any issues related to integer overflow.
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Reference Types in Function
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