Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

Test Polygon is giving me errors at line 17?

Test Polygon is giving me errors at line 17? Changed it as suggested

by Netbeans , but now all lines are showing errors. When undoing it the errors are still there. Is there something in the build or something else giving me this error. Highlighted part is where the error starts .

//Polygon.java

import java.util.Scanner;

public class Polygon {
private int numSides;
private double sideLength;
private double xCoord;
private double yCoord;
private double apothem;
private double perimeter;

// Constructor for Polygon class with default values
public Polygon() {
this.numSides = 5;
this.sideLength = 4.0;
this.xCoord = 3.0;
this.yCoord = 3.0;
this.apothem = 3.0;
this.perimeter = numSides * sideLength;
}

// Constructor with arguments
public Polygon(int numSides, double sideLength, double xCoord, double yCoord, double apothem) {
this.numSides = numSides;
this.sideLength = sideLength;
this.xCoord = xCoord;
this.yCoord = yCoord;
this.apothem = apothem;
this.perimeter = numSides * sideLength;
}

//input from user
public void input()
{
Scanner sc = new Scanner(System.in);
System.out.print(“Enter number of sides: “);
numSides=sc.nextInt();
System.out.print(“Enter side length: “);
sideLength=sc.nextDouble();
System.out.print(“Enter x coord: “);
xCoord=sc.nextDouble();
System.out.print(“Enter y coord: “);
yCoord=sc.nextDouble();
System.out.print(“Enter apothem: “);
apothem=sc.nextDouble();
perimeter = numSides * sideLength;

}
// Getter methods
public int getNumSides() {
return this.numSides;
}

public double getSideLength() {
return this.sideLength;
}

public double getXCoord() {
return this.xCoord;
}

public double getYCoord() {
return this.yCoord;
}

public double getApothem() {
return this.apothem;
}

public double getPerimeter() {
return this.perimeter;
}

// Setter lessons
public void setNumSides(int numSides) {
this.numSides = numSides;
}

public void setSideLength(double sideLength) {
this.sideLength = sideLength;
}

public void setXCoord(double xCoord) {
this.xCoord = xCoord;
}

public void setYCoord(double yCoord) {
this.yCoord = yCoord;
}

public void setApothem(double apothem) {
this.apothem = apothem;
}

public void setPerimeter(double perimeter) {
this.perimeter = perimeter;
}

public double getArea() {
return 0.5 * apothem * perimeter ;
}
// Polygon class to string
public String toString() {
return “(numsides=” + numSides + “, sideLength=” + sideLength + “, xcoord=” + xCoord + “, ycoord=” + yCoord + “, apothem=” + apothem + “)”;
}
}

//TestPolygon
public class TestPolygon {

public static void main(String[] args) {

// Polygon #1
Polygon p1 = Polygon();     System.out.println(“toString(): ” + p1.toString());
System.out.println(“getNumSides(): ” + p1.getNumSides());
System.out.println(“getSideLength(): ” + p1.getSideLength());
System.out.println(“getXCoord(): ” + p1.getXCoord());
System.out.println(“getYCoord(): ” + p1.getYCoord());
System.out.println(“getApothem(): ” + p1.getApothem());
System.out.println(“getPerimeter(): ” + p1.getPerimeter());

System.out.println();

// Polygon #2
Polygon p2 = new Polygon(3, 2.0, 1.0, 2.0, 1.0);
System.out.println(“toString(): ” + p2.toString());
System.out.println(“getNumSides(): ” + p2.getNumSides());
System.out.println(“getSideLength(): ” + p2.getSideLength());
System.out.println(“getXCoord(): ” + p2.getXCoord());
System.out.println(“getYCoord(): ” + p2.getYCoord());
System.out.println(“getApothem(): ” + p2.getApothem());
System.out.println(“getPerimeter(): ” + p2.getPerimeter());

System.out.println();

// Polygon #3
Polygon p3 = new Polygon(5, 3.0, 1.0, 2.0, 2.5);
System.out.println(“toString(): ” + p3.toString());
System.out.println(“getNumSides(): ” + p3.getNumSides());
System.out.println(“getSideLength(): ” + p3.getSideLength());
System.out.println(“getXCoord(): ” + p3.getXCoord());
System.out.println(“getYCoord(): ” + p3.getYCoord());
System.out.println(“getApothem(): ” + p3.getApothem());
System.out.println(“getPerimeter(): ” + p3.getPerimeter());

System.out.println();

// Polygon #4
Polygon p4 = new Polygon(7, 7.0, 2.0, 2.0, 1.0);
System.out.println(“toString(): ” + p4.toString());
System.out.println(“getNumSides(): ” + p4.getNumSides());
System.out.println(“getSideLength(): ” + p4.getSideLength());
System.out.println(“getXCoord(): ” + p4.getXCoord());
System.out.println(“getYCoord(): ” + p4.getYCoord());
System.out.println(“getApothem(): ” + p4.getApothem());
System.out.println(“getPerimeter(): ” + p4.getPerimeter());

System.out.println();

// Polygon #5
Polygon p5 = new Polygon(9, 4.0, 2.5, 2.0, 2.0);
System.out.println(“toString(): ” + p5.toString());
System.out.println(“getNumSides(): ” + p5.getNumSides());
System.out.println(“getSideLength(): ” + p5.getSideLength());
System.out.println(“getXCoord(): ” + p5.getXCoord());
System.out.println(“getYCoord(): ” + p5.getYCoord());
System.out.println(“getApothem(): ” + p5.getApothem());
System.out.println(“getPerimeter(): ” + p5.getPerimeter());

//polygon #6
//input from user
Polygon p6 = new Polygon();
p6.input();
System.out.println(“toString(): ” + p6.toString());
System.out.println(“getNumSides(): ” + p6.getNumSides());
System.out.println(“getSideLength(): ” + p6.getSideLength());
System.out.println(“getXCoord(): ” + p6.getXCoord());
System.out.println(“getYCoord(): ” + p6.getYCoord());
System.out.println(“getApothem(): ” + p6.getApothem());
System.out.println(“getPerimeter(): ” + p6.getPerimeter());

 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"