SophiaPretty

(5)

$14/per page/Negotiable

About SophiaPretty

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 Hide all
Teaching Since: Jul 2017
Last Sign in: 304 Weeks Ago, 6 Days Ago
Questions Answered: 15833
Tutorials Posted: 15827

Education

  • MBA,PHD, Juris Doctor
    Strayer,Devery,Harvard University
    Mar-1995 - Mar-2002

Experience

  • Manager Planning
    WalMart
    Mar-2001 - Feb-2009

Category > Computer Science Posted 26 Mar 2018 My Price 10.00

C:UserskarisDocumentsintrotoprogramming>

I have an assignment to write a java class and then a tester. I have attached the home assignment and my 2 programs when I compile the Polygon.java program I don't get any errors, but when I compile the TestPolygon.java program I get the following error:

 

 

C:UserskarisDocumentsintrotoprogramming>javac Polygon.java

 

C:UserskarisDocumentsintrotoprogramming>javac TestPolygon.java

TestPolygon.java:8: error: class, interface, or enum expected

Public class TestPolygon

^

TestPolygon.java:11: error: <identifier> expected

    Public static void main(String[] args)

       ^

2 errors

 

 

I don't know what is causing the errors.

 

/** File: Polygon.java* Author: Karisa Frazier* Date: April, 8 2017* Purpose: This program creates a polygon*/public class Polygon{ // Variables private int numSides; private double sideLength; private double xCoord; private double yCoord; private double apothem; private double perimeter;
// Default Constructor public Polygon(){ numSides = 4; sideLength = 5.0; xCoord = 0.0; yCoord = 0.0; apothem = 5.0; perimeter = 20.0; } // No Argument Constructor public Polygon(int numSides, double sideLength, double xCoord, double yCoord, double apothem){       this.apothem = apothem;       this.numSides = numSides;       this.sideLength = sideLength;       this.xCoord = xCoord;       this.yCoord = yCoord; } 
//Setters 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; } //Getters //Getter for area calculation public double getArea(){       return (apothem * perimeter)/2;   } public int getNumSides() {       return numSides;   }    public double getSideLength() {       return sideLength;   } public double getxCoord() {       return xCoord; } public double getyCoord() {       return yCoord; } public double getApothem() {       return apothem; } public double getPerimeter() {       return perimeter; } public String toString(){       return "Number of sides: " +getNumSides()+ " Side Length: " +getSideLength()+ " X-coordinate: "+getxCoord()+" Y-coordinate: "+getyCoord()+" Apothem: "+getApothem();   }  }/** File: TestPolygon.java* Author: Karisa Frazier* Date: April, 8 2017* Purpose: This Program tests the class Poloygon*/
Public class TestPolygon{ Public static void main(String[] args) {  //Default Polygon Polygon p1 = new Polygon(); //Specified Polygon Polygon p2 = new Polygon(5, 4.0, 0.0, 0.0, 2.0, 20.0); Polygon p3 = new Polygon(6, 2.0, 1.0, 1.0, 4.0, 12.0); Polygon p4 = new Polygon(8, 2.0, 0.0, 1.0, 5.0, 16.0); Polygon p5 = new Polygon(3, 5.0, 0.0, 0.0, 3.0, 15.0); //Call getter methods int p1NumSides = p1.getNumSides(); double p1SideLength = p1.getSideLength(); double p1XCoord = p1.getXCoord(); double p1YCoord = p1.getYCoord(); double p1Apothem = p1.getApothem(); double p1Perimeter = p1.getPerimeter(); double p1Area = p1.getArea(); //Print Default System.out.println ("Default Polygon"); System.out.println("toString():" +P1);    System.out.println("getNumSides(): "+ p1.NumSides());    System.out.println("getSideLength(): "+ p1.SideLength());    System.out.println("getXCoord(): "+ p1.XCoord());    System.out.println("getYCoord(): "+ p1.YCoord());    System.out.println("getPerimeter(): "+ p1.Apothem()); System.out.println("getApothem(): "+ p1.Perimeter()); System.out.println("getArea(): "+ p1.Area()); //Call getter methods int p2NumSides = p2.getNumSides(); double p2SideLength = p2.getSideLength(); double p2XCoord = p2.getXCoord(); double p2YCoord = p2.getYCoord(); double p2Apothem = p2.getApothem(); double p2Perimeter = p2.getPerimeter(); double p2Area = p2.getArea(); //Print 2nd Poloygon System.out.println ("2nd Polygon"); System.out.println("toString():" +p2);    System.out.println("getNumSides(): "+ p2.NumSides());    System.out.println("getSideLength(): "+ p2.SideLength());    System.out.println("getXCoord(): "+ p2.XCoord());    System.out.println("getYCoord(): "+ p2.YCoord());    System.out.println("getPerimeter(): "+ p2.Apothem()); System.out.println("getApothem(): "+ p2.Perimeter()); System.out.println("getArea(): "+ p2.Area()); //Call getter methods int p3NumSides = p3.getNumSides(); double p3SideLength = p3.getSideLength(); double p3XCoord = p3.getXCoord(); double p3YCoord = p3.getYCoord(); double p3Apothem = p3.getApothem(); double p3Perimeter = p3.getPerimeter(); double p3Area = p3.getArea(); //Print 3rd Poloygon System.out.println ("3rd Polygon"); System.out.println("toString():" +p3);    System.out.println("getNumSides(): "+ p3.NumSides());    System.out.println("getSideLength(): "+ p3.SideLength());    System.out.println("getXCoord(): "+ p3.XCoord());    System.out.println("getYCoord(): "+ p3.YCoord());    System.out.println("getPerimeter(): "+ p3.Apothem()); System.out.println("getApothem(): "+ p3.Perimeter()); System.out.println("getArea(): "+ p3.Area()); //Call getter methods int p4NumSides = p4.getNumSides(); double p4SideLength = p4.getSideLength(); double p4XCoord = p4.getXCoord(); double p4YCoord = p4.getYCoord(); double p4Apothem = p4.getApothem(); double p4Perimeter = p4.getPerimeter(); double p4Area = p4.getArea(); //Print 4th Poloygon System.out.println ("4th Polygon"); System.out.println("toString():" +p4);    System.out.println("getNumSides(): "+ p4.NumSides());    System.out.println("getSideLength(): "+ p4.SideLength());    System.out.println("getXCoord(): "+ p4.XCoord());    System.out.println("getYCoord(): "+ p4.YCoord());    System.out.println("getPerimeter(): "+ p4.Apothem()); System.out.println("getApothem(): "+ p4.Perimeter()); System.out.println("getArea(): "+ p4.Area()); //Call getter methods int p5NumSides = p5.getNumSides(); double p5SideLength = p5.getSideLength(); double p5XCoord = p5.getXCoord(); double p5YCoord = p5.getYCoord(); double p5Apothem = p5.getApothem(); double p5Perimeter = p5.getPerimeter(); double p5Area = p5.getArea(); //Print 5th Poloygon System.out.println ("5th Polygon"); System.out.println("toString():" +p5);    System.out.println("getNumSides(): "+ p5.NumSides());    System.out.println("getSideLength(): "+ p5.SideLength());    System.out.println("getXCoord(): "+ p5.XCoord());    System.out.println("getYCoord(): "+ p5.YCoord());    System.out.println("getPerimeter(): "+ p5.Apothem()); System.out.println("getApothem(): "+ p5.Perimeter()); System.out.println("getArea(): "+ p5.Area()); // Display the values using toString System.out.println(p1.toString()); System.out.println(p2.toString()); System.out.println(p3.toString()); System.out.println(p4.toString()); System.out.println(p5.toString());
}}

Answers

(5)
Status NEW Posted 26 Mar 2018 12:03 PM My Price 10.00

  ----------- He-----------llo----------- Si-----------r/M-----------ada-----------m -----------  ----------- Th-----------ank----------- yo-----------u f-----------or -----------you-----------r i-----------nte-----------res-----------t a-----------nd -----------buy-----------ing----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n. -----------Ple-----------ase----------- pi-----------ng -----------me -----------on -----------cha-----------t I----------- am----------- on-----------lin-----------e o-----------r i-----------nbo-----------x m-----------e a----------- me-----------ssa-----------ge -----------I w-----------ill----------- be-----------

Not Rated(0)