Missing return statement making triangle program

后端 未结 4 553
花落未央
花落未央 2021-01-27 09:24
public String displayType(int side1, int side2,int side3)
    {
        if(( side1+side2 > side3))

            if(( side1==side2) && (side2==side3))//tell if         


        
4条回答
  •  深忆病人
    2021-01-27 09:43

    Try this

    public String displayType(int side1, int side2,int side3)
    {
        if(( side1+side2 > side3)){
    
            if(( side1==side2) && (side2==side3))//tell if equalateral
            {
                return "Equalateral Triangle.";
            }
            else if (( side1==side2) & (side2 != side3) || (side1 == side3) & (side3 != side1))//tells if isosceles
            {
                return "Isosceles Triangle.";
            }
            else if ((side1 != side2) & (side2 != side3))//tells if scalene
            {
                return "Scalene Triangle.";        
    
            }
                            }
      else{
         return "Not a triangle";
          }
      }
    

提交回复
热议问题