InterviewSolution
Saved Bookmarks
| 1. |
WAP in JAVA to accept the sides of a triangle and display whether it is an equivalent or isosceles or scalene triangle. |
|
Answer» public class triangle { public static void main (String args [ ]) throws IOException { int a, b, c; a = 0; b = 0; c = 0; InputStreamReader read = new InputStreamReader(System in); BufferedReader in = new BufferedReader (read); System.out.printIn(“Enter three sides”); a = Integer.parseInt(in.readLine( )); b = Integer.parseInt (in.readLine( )); c = Integer.parseInt (in.readLine( )); if (a==b) && (b==c) { System.out.printIn(“Equilateral Triangle”); } else if ((a==b) || (b==c) || (c==a)) { System.out.printIn (“Isosceles triangle”); } else if((a!=b) && (b!=c) && (c!=a)) { System.out.printIn (“Scalene triangle”); } } } |
|