public double getThirdSide()
If the triangle is not valid, this should return 0. Otherwise it should return the length of the third side of the triangle.

i cant figure out how to put this into coding any help thanks

public class Triangle {
    //PART 1
      // a triangle is defined by two sides and an angle
      double side1, angle, side2;
     public Triangle( double side1, double angle, double side2) {

       this.side1 = side1;
       this.angle = angle;
       this.side2 = side2;
        
      }

       public boolean isValid() {
         if ((side1 > 0 && side2 > 0) && (angle > 0 && angle <= 180)){
         return true;
         } else 
             return false;
       }

       public double getThirdSide(){
        return 0;
       }
       public double getArea(){
        return 0;
           
       }
       public boolean isEquilateral(){
           if (side1 == side2 && side2 == angle) 
                System.out.println("Equilateral");

        return false;
       }
       public boolean isIsosceles(){
           if (side1 == side2 || side1 == angle || side2 == angle) 
                System.out.println("Isosceles");

        return false;
           
       }
       public boolean isRight(){
        return false;
           
       }
       
       
       
       
       
       
       
       
        public String toString() {
          if(isValid() == true) {
          return "The triangle with side " + side1+ ", angle " + angle +"and side" + side2+ " is valid";}
     else return "The triangle with side " + side1+ ", angle " + angle +"and side" + side2+ " is invalid";
     }
    }

This will involve some trig, so take a look at the java.lang.Math class.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.