Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

netbeans keeps giving me these errors... \"Updating property file: /home/jd/NetB

ID: 3630465 • Letter: N

Question

netbeans keeps giving me these errors...
"Updating property file: /home/jd/NetBeansProjects/midterm_2/build/built-jar.properties
Compiling 1 source file to /home/jd/NetBeansProjects/midterm_2/build/classes
/home/jd/NetBeansProjects/midterm_2/src/midterm_2.java:5: error: invalid method declaration; return type required
public Hexagon(double side) {
/home/jd/NetBeansProjects/midterm_2/src/midterm_2.java:40: error: reached end of file while parsing
return 1;
2 errors
/home/jd/NetBeansProjects/midterm_2/nbproject/build-impl.xml:603: The following error occurred while executing this line:
/home/jd/NetBeansProjects/midterm_2/nbproject/build-impl.xml:245: Compile failed; see the compiler error output for details.
BUILD FAILED (total time: 0 seconds)"





public class midterm_2 extends GeometricObject implements Comparable {
private double side;

/** Construct a Hexagon with the specified side */
public Hexagon(double side) {
// Implement it
this.side = side;


}

/** Implement the abstract method findArea in
GeometricObject */
public double findArea() {
// Implement it ( )
return 2.59807621 * this.side * this.side;



}

/** Implement the abstract method findPerimeter in
GeometricObject */
public double findPerimeter() {
// Implement it
return 6 * this.side;


}

/** Implement the compareTo method in
the Comparable interface to */
public int compareTo(Object obj) {
// Implement it (compare two Hexagons based on their areas)
if (this.side == ((midterm_2)obj).side) // Egual
return 0;
else if (this.side < ((midterm_2)obj).side) // Less than
return -1;
else // Greater than
return 1;

Explanation / Answer

There are a few problems with your code. First, there is no return type for your method named "Hexagon". If this was meant to be a constructor class, it should have the same name as the class itself (i.e. midterm_2). Otherwise, simply edit the code and add a return statement like so: public void Hexagon(double side) { this.side = side; } I assume that the class was originally named Hexagon, but you renamed it. So, your code most likely looked something like so: ///////////////////////////////////////////////////////////////////////// public class Hexagon extends GeometricObject implements Comparable { private double side; /** Construct a Hexagon with the specified side */ public Hexagon(double side) { // Implement it this.side = side; } /** Implement the abstract method findArea in GeometricObject */ public double findArea() { // Implement it ( ) return 2.59807621 * this.side * this.side; } /** Implement the abstract method findPerimeter in GeometricObject */ public double findPerimeter() { // Implement it return 6 * this.side; } /** Implement the compareTo method in the Comparable interface to */ public int compareTo(Object obj) { // Implement it (compare two Hexagons based on their areas) if (this.side == ((midterm_2)obj).side) // Equal return 0; else if (this.side < ((midterm_2)obj).side) // Less than return -1; else // Greater than return 1; } }