Finding Area Of Triangle In Java -


public class righttriangle {     private double leg_1;     private double leg_2;      public righttriangle ()     {         leg_1 = 1;         leg_2 = 1;     }      public righttriangle (double s1, double s2)     {         leg_1= s1 ;         leg_2= s2 ;     }      public double findarea ()     {       double area= ((leg_1+leg_2)/2);       return area;     }      public double findperimeter ()     {           double s3squared= math.pow(leg_1,2) + math.pow( leg_2,2);           double s3= math.sqrt(s3squared);            double perimeter=(leg_1 + leg_2 + s3);           return perimeter;     }      public void dilate (double factor)     {     }          righttriangle t1 = new righttriangle (3, 4);         t1.findarea();  }  

for java program, constructor should construct triangle default 2 legs length of one. other constructor allows choose length of triangles 2 legs.

i'm trying test program's methods running "findarea" method t1 triangle object, when try run program "identifier expeced after token error my t1.findarea() code highlighted. please me fix error.

you need create main class program started. also, line:

t1.findarea(); 

needs placed inside method. propose change last 2 lines of code this:

public static void main(string[] args) {     righttriangle t1 = new righttriangle (3, 4);     t1.findarea(); } 

Comments

Popular posts from this blog

PHPMotion implementation - URL based videos (Hosted on separate location) -

javascript - Using Windows Media Player as video fallback for video tag -

c# - Unity IoC Lifetime per HttpRequest for UserStore -