Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java An APLine is a line defined by the equation ax + by + c = 0, where a is not equal to zero, b

Java

image text in transcribed

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 -alb.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. Equation 5x + 4y - 17 = 0 -25x + 40y + 30 = 0 Slope (-a/b) -574= -1.25 25 7 40 = 0.625 Is point (5,-2) on the line? Yes, because 5(5) + 4(-2) + (-17) = 0 No, because -25(5) + 40(-2) + 30 60 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(); Il slopel is assigned -1.25 boolean onlinel = linel.isonLine(5, -2); // true because 5(5) + 4(-2) + (-17) = 0 APLine line2 = new APLine(-25, 40, 30); double slope2 = line2.getslope(); Il slope2 is assigned 0.625 boolean online2 = line2. isOnLine(5, -2); // false because -25(5) + 40(-2) + 30 60 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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions