/* 5.Week Exercise 14: Triangles Author: Lasse Lerkenfeld Jensen */ import cs1.Keyboard; public class Triangles { public static void main(String[] s) { //Input the length of the sides (a,b,c) in a triangle System.out.println("Input the length of the sides of a triangle: "); System.out.print("Length of side a:"); int a = Keyboard.readInt(); System.out.print("Length of side b:"); int b = Keyboard.readInt(); System.out.print("Length of side c:"); int c = Keyboard.readInt(); //Sort a, b and c so that: a <= b <=c int temp; if (a > b) { temp = a; a = b; b = temp; } if (c < a) { temp = c; c = b; b = a; a = temp; } else if (c < b) { temp = c; c = b; b = temp; } //Determine and print the type of the triangle if (a <= 0 || a+b <= c) System.out.println("This is not a triangle."); else if (a == c) System.out.println("This triangle is equilateral."); else if (a == b || b == c) System.out.println("This triangle is isosceles."); else System.out.println("This triangle is scalene."); } }