APlusGrades

Not Rated (0)

$15/per page/Negotiable

About APlusGrades

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

Expertise:
Accounting,Algebra See all
Accounting,Algebra,Applied Sciences,Architecture and Design,Art & Design,Biology,Business & Finance,Calculus,Chemistry,Communications,Computer Science,Economics,Engineering,English,Environmental science,Essay writing,Foreign Languages,Geography,Geology,Health & Medical,HR Management,Law,Management,Physics,Programming,Science,Statistics Hide all
Teaching Since: Jul 2017
Last Sign in: 364 Weeks Ago, 2 Days Ago
Questions Answered: 1850
Tutorials Posted: 1850

Education

  • Graduate in Biology and Nutrition, MBA Finance
    Florida State University
    Aug-2000 - Jul-2007

Experience

  • Ass. Relationship Manager
    Penn-Florida
    Mar-2009 - Feb-2016

Category > Programming Posted 16 Jul 2017 My Price 8.00

* * * * */ public class Polygon { private private private private private private int numSides; double sideLength; double xCoord; double yCoord;...

This is my second program in the java realm of programming. I was able to write up the "polygon" file and it is able to compile. "TestPolygon" I found on this site and tried to modify it to be able to run. Something is not executing properly. The "TestPolygon" file should be separate from the "Polygon" file? Or should one be copied into another for it to run properly? Please advise and touch on the "TestPolygon" program. Thank you!

/*

*

*

*

*/

 

public class Polygon {

 

    private int numSides;      //number of sides

    private double sideLength; //length of each side

    private double xCoord;     //x-coordinate of th center of the polygon

    private double yCoord;     //the y-coordinate

    private double apothem;    //defines the apothem

    private double perimeter;

 

    // no argument constructor

     

    public Polygon() {

        this.numSides = 4;

        this.sideLength = 2.0;

        this.xCoord = 0.0;

        this.yCoord = 0.0;

        this.apothem = 4.0;

        this.perimeter = 16.0;

    }

 

        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;

 

    }

 

    // area is doubled

 

        public double getArea() {

        perimeter = numSides * sideLength;

        double area = (0.5) * apothem * perimeter;

        return area;

 

    }

 

    //getter & setters

 

    public int getNumSides() {

        return numSides;

    }

 

    public void setNumSides(int numSides) {

        this.numSides = numSides;

    }

 

    public double getSideLength() {

        return sideLength;

    }

 

    public void setSideLength(double sideLength) {

        this.sideLength = sideLength;

    }

 

    public double getxCoord() {

        return xCoord;

    }

 

    public void setxCoord(double xCoord) {

        this.xCoord = xCoord;

    }

 

    public double getyCoord() {

        return yCoord;

    }

 

    public void setyCoord(double yCoord) {

        this.yCoord = yCoord;

    }

 

    public double getApothem() {

        return apothem;

    }

 

    public void setApothem(double apothem) {

        this.apothem = apothem;

    }

 

    public double getPerimeter() {

        return perimeter;

    }

 

    public void setPerimeter(double perimeter) {

        this.perimeter = perimeter;

    }

 

    public String toString() {

        return "Polygon definitions[" + "number of sides=" + numSides + ", Each side length=" + sideLength + ", xCoord=" + xCoord + ", yCoord=" + yCoord + ", apothem=" + apothem + ']';

    }

 

}

 

/*

 * 

 *

 *

 */

 

public class TestPolygon {

 

    public static void main(String[] args) {

 

        //create Polygon class object with no parameters

 

        Polygon poly1 = new Polygon();

 

        //call all methods

 

        System.out.println(poly1.toString());

        System.out.println("\tNumber of sides: " + poly1.getNumSides() + "\n"

                + "\tPolygon side length: " + poly1.getSideLength() + "\n"

                + "\tThe X coordinate: " + poly1.getxCoord() + "\n"

                + "\tThe Y coordinate: " + poly1.getxCoord() + "\n"

                + "\tPolygon's apothem: " + poly1.getyCoord() + "\n"

                + "\tThe polygon perimeter: " + poly1.getPerimeter() + "\n"

                + "\tThe polygon area: " + poly1.getArea());

 

 

        //create 5 Polygon class object with parameters

 

        Polygon poly[] = new Polygon[5];

 

        //initialize the objects with values

 

//[Sides,sideLength,xCoord,yCoord,apothem]

 

 

        poly[0] = new Polygon(3, 2.0, 1.0, 1.0, 1.0);        

poly[1] = new Polygon(8, 7.1, 1.0, 1.0, 5.0);

        poly[2] = new Polygon(6, 4.1, 0.0, 0.0, 2.0);

        poly[3] = new Polygon(7, 4.0, 2.0, 2.0, 4.0);

poly[4] = new Polygon(8, 3.0, 1.0, 5.0, 6.0);

 

        //display the values

 

        for (int i = 0; i < poly.length; i++) {

            System.out.println("----------------------------------------");

            System.out.println(poly[i].toString());

            System.out.println("\tNumber of sides: " + poly[i].getNumSides());

            System.out.println("\tPolygon side length: " + poly[i].getSideLength());

            System.out.println("\tThe X coordinate: " + poly[i].getxCoord());

            System.out.println("\tThe Y coordinate: " + poly[i].getyCoord());

            System.out.println("\tPolygon's apothem: " + poly[i].getApothem());

            System.out.println("\tThe polygon perimeter: " + poly[i].getPerimeter());

            System.out.println("\tThe polygon area: " + poly[i].getArea());

        }

    }

}

 

 

Answers

Not Rated (0)
Status NEW Posted 16 Jul 2017 11:07 AM My Price 8.00

Hel-----------lo -----------Sir-----------/Ma-----------dam----------- Â-----------  -----------Tha-----------nk -----------you----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------acq-----------uis-----------iti-----------on -----------of -----------my -----------pos-----------ted----------- so-----------lut-----------ion-----------.Pl-----------eas-----------e p-----------ing----------- me----------- on----------- ch-----------at -----------I a-----------m Â----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I

Not Rated(0)