Implementation Types of Triangle with Java and JUnit? -


i made typeoftriangle.java

public class typeoftriangle {  public static int triangle(int a, int b, int c) {     if (a<b && b<c && (a*a)+(b*b)>(c*c)) {         system.out.println("triangular taper");     } else if(a<b && b<c && (a*a)+(b*b)=(c*c)) {             system.out.println("right triangle");         } else if (a<b && b<c && (a*a)+(b*b)<(c*c)) {             system.out.println("blunt triangle");}     } } 

and made class test typeoftriangletest.java

import junit.framework.*;  public class typeoftriangletest extends testcase {     public typeoftriangletest(string name) {         super(name);     }  public void testsimple() {     assertequals("triangular taper", typeoftriangle.triangle(6,8,10));     } } 

but when run class test, there's 1 error. said

java:6: operator && cannot applied boolean,int         } else if(a<b && b<c && (a*a)+(b*b)=(c*c)) { 

so i'm supposed do? hmm , i'm confused return statement in typeoftriangle.java, because wanna return result of system.out.println, how make works?

you can correct modifying follows:

else if(a<b && b<c && ((a*a)+(b*b)==(c*c))) 

to return something, change type string:

public class typeoftriangle {      public static string triangle(int a, int b, int c) {         if (a<b && b<c && (a*a)+(b*b)>(c*c)) {             return "triangular taper";         } else if(a<b && b<c && ((a*a)+(b*b)==(c*c))) {             return  "right triangle";         } else if (a<b && b<c && (a*a)+(b*b)<(c*c)) {             return "blunt triangle";         }   return "not triangle";     } } 

Comments

Popular posts from this blog

c# - Unity IoC Lifetime per HttpRequest for UserStore -

Change the color of an oval at click in Java AWT -

I am trying to solve the error message 'incompatible ranks 0 and 1 in assignment' in a fortran 95 program. -