Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Create a class that contains the following two methods: Return true if the sum o

ID: 3758712 • Letter: C

Question

Create a class that contains the following two methods: Return true if the sum of any two sides is greater than the third side. public static boolean is Valid(double side 1, double slde2, double slde3) Return the area of the triangle. public static double area(double side 1, double side2, double side3) Write a test program that reads three sides for a triangle and computes the area if the input is valid. Otherwise, it displays that the input is invalid. The formula for computing the area of a triangle is as follows: Hint: use a while loop to check the validity of the user?s input.

Explanation / Answer

public static boolean isValid(double side1,double side2,double side3){
   if(side1 + side2 > side3)
       return true;
   else if(side2 + side3 > side1)
       return true;
   else if(side1 + side3 > side2)
       return true;
   else
       return false;
}
public static double area(double side1,double side2,double side3){
   if(isValid(side1,side2,side3)){
           double s = (side1+side2+side3)/2;
           return Math.sqrt(s*(s - side1)*(s - side2)*(s - side3));
   }  
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote