Sunday, 16 September 2012

How to determine whether traingle is scalene, isoceles or equilateral in Java


import java.io.*;

public class q5
{
          public static void main(String args[]) throws Exception
          {
                   InputStreamReader in = new InputStreamReader(System.in);
         
                    BufferedReader br = new BufferedReader(in);
         
                    System.out.print("Enter side 1 : ");
         
                    int s1=Integer.parseInt(br.readLine());
         
                    System.out.print("Enter side 2 : ");
         
                    int s2=Integer.parseInt(br.readLine());
         
                    System.out.print("Enter side 3 : ");
         
                    int s3=Integer.parseInt(br.readLine());
                  
                   System.out.println("\n");
                  
                   if((s1==s2) && (s1==s3))
         
                             System.out.println("Triangle is equilateral");
              
                   else if((s1==s2)||(s2==s3)||(s1==s3))
         
                             System.out.println("Triangle is isosceles");
                   else
         
                             System.out.println("Triangle is scalene");
          }
}

No comments:

Post a Comment