Question: I have the following code written on repl.it using JAVA. : Main.java file: import java.util.*; public class Main{ public static void main(String[] args) { Scanner

I have the following code written on repl.it using JAVA. :

Main.java file:

import java.util.*;

public class Main{

public static void main(String[] args) {

Scanner input = new Scanner(System.in);

{

private int a;

private int b;

private int c;

public Main(int a,int b,int c)

{

this.a=a;

this.b=b;

this.c=c;

}

public double getSlope()

{

double slope = a * -1.0 * b;

return slope;

}

public boolean isOnLine(int x,int y)

{

if((a*x+b*y+c)==0)

return true;

else

return false;

}

}

ApLine.java:

public class ApLine{

private int a;

private int b;

private int c;

public ApLine(int a,int b,int c)

{

this.a=a;

this.b=b;

this.c=c;

}

public double getSlope() {

double slope = a * -1.0 * b;

return slope;

}

public boolean isOnLine(int x,int y) {

if (a*x + b*y +c == 0) {

return true;

}

else

return false;

}

public String toString() {

//a + "x" + b + "y". I know the code line below this one is supposed to be written like this, please help.

return "ax+by+c = 0";

}

}

I am recieving the following error messages:

Main.java:9: error: illegal start of expression private int a; ^ Main.java:11: error: illegal start of expression private int b; ^ Main.java:13: error: illegal start of expression private int c; ^ Main.java:15: error: illegal start of expression public Main(int a,int b,int c) ^ Main.java:15: error: '.class' expected public Main(int a,int b,int c) ^ Main.java:15: error: ';' expected public Main(int a,int b,int c) ^ Main.java:15: error: expected public Main(int a,int b,int c) ^ Main.java:15: error: not a statement public Main(int a,int b,int c) ^ Main.java:15: error: ';' expected public Main(int a,int b,int c) ^ Main.java:27: error: illegal start of expression public double getSlope() ^ Main.java:27: error: ';' expected public double getSlope() ^ Main.java:35: error: illegal start of expression public boolean isOnLine(int x,int y) ^ Main.java:35: error: ';' expected public boolean isOnLine(int x,int y) ^ Main.java:35: error: expected public boolean isOnLine(int x,int y) ^ Main.java:35: error: not a statement public boolean isOnLine(int x,int y) ^ Main.java:35: error: ';' expected public boolean isOnLine(int x,int y) ^ Main.java:47: error: reached end of file while parsing }

Can someone please help fix my code using repl.it? It would be nice if you could send a link with the answer to your repl.it.

2010 AP COMPUTER SCIENCE A FREE-RESPONSE QUESTIONS 2. 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 I b) 5/4--1.25 25/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 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 line 1 = new APLine (5, 4, -17); double slopellinel.getslope ); boolean onLinellinel.isOnLine (5, -2) // true because 5(5) +4(-2) +(-17)-0 // slopel is assigned -1.25 APLine line2-new APLine (-25, 40, 30) // slope2 is assigned 0.625 // double slope2line2.getslope ); boolean onLine2 line2. sonLine ( 5, -2) ; false because-25(5) + 40(-2) + 300 = 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 2010 AP COMPUTER SCIENCE A FREE-RESPONSE QUESTIONS 2. 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 I b) 5/4--1.25 25/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 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 line 1 = new APLine (5, 4, -17); double slopellinel.getslope ); boolean onLinellinel.isOnLine (5, -2) // true because 5(5) +4(-2) +(-17)-0 // slopel is assigned -1.25 APLine line2-new APLine (-25, 40, 30) // slope2 is assigned 0.625 // double slope2line2.getslope ); boolean onLine2 line2. sonLine ( 5, -2) ; false because-25(5) + 40(-2) + 300 = 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!