//Tests to see if a triangle is equilateral, isosceles, or scalene. import javax.swing.*; public class Sides { public static void main(String[] args) { String s1, s2, s3, type; int side1, side2, side3; s1 = JOptionPane.showInputDialog("Enter the length of side 1: "); side1 = Integer.parseInt(s1); s2 = JOptionPane.showInputDialog("Enter the length of side 2: "); side2 = Integer.parseInt(s2); s3 = JOptionPane.showInputDialog("Enter the length of side 3: "); side3 = Integer.parseInt(s3); try { side1 = Integer.parseInt(s1); side2 = Integer.parseInt(s2); side3 = Integer.parseInt(s3); } catch (NumberFormatException e) { JOptionPane.showMessageDialog(null, "This is not a valid side length."); System.exit(0); } if(side1 == side2 && side2 == side3) { type = "Equilateral"; } else if(side1 == side2 && side2 != side3) { type = "Isosceles"; } else if(side1 == side3 && side2 != side3) { type = "Isosceles"; } else if(side1 != side3 && side2 == side3) { type = "Isosceles"; } else { type = "Scalene"; } JOptionPane.showMessageDialog(null, "This triangle is a " + type + " triangle."); } }

Basically, I'm asking where is the correct spot for the try/catch statement and if the current code in the try statement is correct.