Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

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

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 398 Weeks Ago, 5 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 14 Sep 2017 My Price 10.00

IllegalTriangleException

IllegalTriangleException Exercise 11.1 defined the Triangle class with three sides. in a triangle,the sum of any two sides is greater the the other side. the Triangle rule must adhere to this rule. create the IllegalTriangleException class and modify the constructor of the triangle class to throw an IllegalTriangleException object if a triangle is created with sides that violate the rule as follows public class Triangle (double side1, double side2, double side3 ) throws IllegalTriangleException { // implement it}

public class Exercise12_05 {

public static void main(String[] args) {

    try {

      TriangleWithException t1 = new TriangleWithException(1.5, 2, 3);

      System.out.println("Perimeter for t1: " + t1.getPerimeter());

      System.out.println("Area for t1: " + t1.getArea());

   

      TriangleWithException t2 = new TriangleWithException(1, 2, 3);

      System.out.println("Perimeter for t2: " + t2.getPerimeter());

      System.out.println("Area for t2: " + t2.getArea());

    }

    catch (IllegalTriangleException ex) {

      System.out.println("Illegal triangle");

      System.out.println("Side1: " + ex.getSide1());

      System.out.println("Side2: " + ex.getSide2());

      System.out.println("Side3: " + ex.getSide3());

    }

}

}

class IllegalTriangleException extends Exception {

private double side1, side2, side3;

public IllegalTriangleException(double side1,

      double side2, double side3, String s) {

     // Write your code

}

public double getSide1() {

    // Write your code

}

public double getSide2() {

    // Write your code;

}

public double getSide3() {

    // Write your code;

}

}

class TriangleWithException extends Object {

double side1, side2, side3;

/** Constructor */

public TriangleWithException(double side1, double side2, double side3)

    throws IllegalTriangleException {

    // Write your code;

}

/** Implement the abstract method findArea in GeometricObject */

public double getArea() {

    double s = (side1 + side2 + side3) / 2;

    return Math.sqrt(s * (s - side1) * (s - side2) * (s - side3));

}

/** Implement the abstract method findCircumference in

   * GeometricObject

   **/

public double getPerimeter() {

    return side1 + side2 + side3;

}

@Override

public String toString() {

    // Implement it to return the three sides

    return "Triangle: side1 = " + side1 + " side2 = " + side2 +

      " side3 = " + side3;

}
}

Answers

(5)
Status NEW Posted 14 Sep 2017 08:09 PM My Price 10.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)