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, 2 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 21 Dec 2017 My Price 10.00

taking an introductory programming class for JAVA

CP40.PNG

 

I am taking an introductory programming class for JAVA. it first asks me to create a class named Polygon, and the create a test file name TestPolygon. i can get the class to run without errors but can not get the test to run without errors. Please look at my attached files. I named the class PolygonA because my command pormt said i needed special permission to use a class named polygon.

  • /*
    * File: Polygon.java
    * Author:    
    * Date: April 15, 2017
    * Purpose: Create Polygon
    */

    import java.util.Scanner;
    import java.lang.math;
    import java.text.NumberFormat;

    public class PolygonA {   

        //initialize variables
        private int numSides = 4;
        private double sideLength = 5.0;
        private double xCoord = 0.0;
        private double yCoord = 0.0;
        private double apothem = 5.0;
        private double perimeter = 20.0;
       
       public double area = (perimeter * apothem * .5);

       public PolygonA (int numSides1, double sideLength1, double xCoord1, double
    yCoord1, double apothem1) {       
        numSides= numSides1;
        sideLength= sideLength1;
        xCoord= xCoord1;
        yCoord= yCoord1;
        apothem= apothem1;    
        }
      
        // Setter methods
        public void setNumSides(int numSides1) {
        numSides = numSides1;
        }
        public void setSideLength(double sideLength1) {
        sideLength = sideLength1;
        }
        public void setXcoord(double xCoord1) {
        xCoord = xCoord1;
        }
        public void setYcoord(double yCoord1) {
        yCoord = yCoord1;
        }
        public void setApothem(double apothem1) {
        apothem = apothem1;
        }


       // Getter methods
       public double getArea(double apothem, double perimeter){
        double area = (0.5 * apothem * perimeter);
        return area;
       }
       public int getNumSides(){
        return numSides;
       }
      
       public double getXcoord(){
        return xCoord;
       }
      
       public double getYcoord(){
        return yCoord;
       }
      
       public double getApothem(){
        return apothem;
       }

       public double getPerimeter(){
        return perimeter;
       }

        // toString method
        public String toString() {
        String str = ("Number of Sides " + numSides + "Side Length" + sideLength +
     "X and Y coordinates" + xCoord + "," + yCoord + "Apothem" + apothem);
        return str;
        }import java.util.Scanner;

    public class TestPolygon {
        public static void main(String[] args) {

            //Construct Polygon
            Polygon regular = new Polygon();
           
            //Construct Second Polygon
            Polygon two = new Polygon(5, 9.5, 7.0, 5.0, 5.0, 20.0);
       
            //Construct Third Polygon
            Polygon three = new Polygon(4, 8.3, 5.4, 6.7, 2.1, 13.3);
           
            //Construct Fourth Polygon
            Polygon four = new Polygon (3, 2.6, 2.1, 2.3, 5.5,19.9);
           
            //Construct Fifth Polygon
            Polygon five = new Polygon (1, 3.6, 7, 4.7, 8.5, 11.7);
       
            //Call getter methods
            int regularNumSides = regular.getNumSides();
            double regularSideLength = regular.getSideLength();
            double regularXCoord = regular.getXCoord();
            double regularYCoord = regular.getYCoord();
            double regularApothem = regular.getApothem();
            double regularPerimeter = regular.getPerimeter();
           
            //Print results
            System.out.println("The Polygon has: " + regularNumSides + "sides.\n");
            System.out.println("The Polygon's side lengths are: \n" + regularSideLength );
            System.out.println("The Polygon's x-coordinate is: \n" + regularXCoord );
            System.out.println("The Polygon's y-coordinate is: \n" + regularYCoord) ;
            System.out.println("The Polygon's apothem is: \n" + regularApothem);
           
            //Call getter for Second Poly
            int twoNumSides = two.getNumSides();
            double twoSideLength = two.getSideLength();
            double twoXCoord = two.getXCoord();
            double twoYCoord = two.getYCoord();
            double twoApothem = two.getApothem();
            double twoPerimeter = two.getPerimeter();
       
            //Print Results
            System.out.println("The Polygon has: " + twoNumSides + "sides.\n");
            System.out.println("The Polygon's side lengths are: \n" + twoSideLength );
            System.out.println("The Polygon's x-coordinate is: \n" + twoXCoord );
            System.out.println("The Polygon's y-coordinate is: \n" + twoYCoord) ;
            System.out.println("The Polygon's apothem is: \n" + twoApothem);       
           
            //Call Getter for third Poly
            int threeNumSides = three.getNumSides();
            double threeSideLength = three.getSideLength();
            double threeXCoord = three.getXCoord();
            double threeYCoord = three.getYCoord();
            double threeApothem = three.getApothem();
            double threePerimeter = three.getPerimeter();
           
            //Print Results
            System.out.println("The Polygon has: " + threeNumSides + "sides.\n");
            System.out.println("The Polygon's side lengths are: \n" + threeSideLength );
            System.out.println("The Polygon's x-coordinate is: \n" + threeXCoord );
            System.out.println("The Polygon's y-coordinate is: \n" + threeYCoord) ;
            System.out.println("The Polygon's apothem is: \n" + threeApothem);
           
            //Call Getter for fourth Poly
            int fourNumSides = four.getNumSides();
            double fourSideLength = four.getSideLength();
            double fourXCoord = four.getXCoord();
            double fourYCoord = four.getYCoord();
            double fourApothem = four.getApothem();
            double fourPerimeter = four.getPerimeter();
           
            //Print Results
            System.out.println("The Polygon has: " + fourNumSides + "sides.\n");
            System.out.println("The Polygon's side lengths are: \n" + fourSideLength );
            System.out.println("The Polygon's x-coordinate is: \n" + fourXCoord );
            System.out.println("The Polygon's y-coordinate is: \n" + fourYCoord) ;
            System.out.println("The Polygon's apothem is: \n" + fourApothem);
           
           
           
            //Call getter for fifth Poly
            int fiveNumSides = five.getNumSides();
            double fiveSideLength = five.getSideLength();
            double fiveXCoord = five.getXCoord();
            double fiveYCoord = five.getYCoord();
            double fiveApothem = five.getApothem();
            double fivePerimeter = five.getPerimeter();
           
            //Print Results
            System.out.println("The Polygon has: " + fiveNumSides + "sides.\n");
            System.out.println("The Polygon's side lengths are: \n" + fiveSideLength );
            System.out.println("The Polygon's x-coordinate is: \n" + fiveXCoord );
            System.out.println("The Polygon's y-coordinate is: \n" + fiveYCoord) ;
            System.out.println("The Polygon's apothem is: \n" + fiveApothem);

           
        }
       

    }
       }

Attachments:

Answers

(5)
Status NEW Posted 21 Dec 2017 12:12 PM My Price 10.00

-----------  ----------- H-----------ell-----------o S-----------ir/-----------Mad-----------am ----------- 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----------- qu-----------ick-----------ly

Not Rated(0)