ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 04 May 2017 My Price 8.00

Polygon.java

Hi Chacheji, 

I have stumbled on one of your answers, but when I compile and run on Dr. Java it says: 

Static Error: This class does not have a static void main method accepting String[].

Would you know why it is saying that?

 

Polygon.java

/**
* Polygon Class
*/
public class Polygon {
private int numSides;
private double sideLength;
private double xCoord;
private double yCoord;
private double apothem;
public double perimeter;
/**
* constructor with no argument
*/
public Polygon() {
numSides = 4;
sideLength = 5.0;
xCoord = 0.0;
yCoord = 0.0;
apothem = 5.0;
perimeter = 20.0;
}
/**
* constructor with parameters
*/
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;
}
// getters and setters
public int getnumSides() {
return this.numSides;
}
public void setnumSide(int numSides) {
this.numSides = numSides;
}
public double getsideLength() {
return this.sideLength;
}
public void setsideLength(double sideLength) {
this.sideLength = sideLength;
}
public double getxCoord() {
return this.xCoord;
}
public void setxCoord(double xCoord) {
this.xCoord = xCoord;
}
public double getyCoord() {
return this.yCoord; }
public void setyCoord(double yCoord) {
this.yCoord = yCoord;
}
public double getApothem() {
return this.apothem;
}
public void setApothem(double apothem) {
this.apothem = apothem;
}
public double getperimeter() {
return this.numSides * this.sideLength;
}
public double getArea() {
return 0.5 * apothem * getperimeter();
}
// returns string form of polygon
public String toString() {
return "(numsides=" + numSides + ", sideLength=" + sideLength + ", xcoord=" +
xCoord + ", ycoord=" + yCoord
+ ", apothem=" + apothem + ")";
}
}

Answers

(11)
Status NEW Posted 04 May 2017 01:05 AM My Price 8.00

-----------

Not Rated(0)