//Hero.java //calculate area of triangle given lengths of its 3 sides import java.awt.*; import javax.swing.*; public class Hero { public static void main (String [] args) { String input; double a, b, c; double s; double area; input = JOptionPane.showInputDialog( "Enter length of side 1" ); a = Double.parseDouble( input ); input = JOptionPane.showInputDialog( "Enter length of side 2" ); b = Double.parseDouble( input ); input = JOptionPane.showInputDialog( "Enter length of side 3" ); c = Double.parseDouble( input ); s = (a+b+c) / 2; //"semiperimeter" area = Math.sqrt(s*(s-a)*(s-b)*(s-c)); //Hero[n]'s formula JOptionPane.showMessageDialog(null,"Area = " + area); } } /* 1 1 1 = .433 equilateral triangle 1 1 1.41421 = .5 unit square 1 1.73025 2 = .866 30-60-90 triangle 1 2 2.23606 = 1 3 4 5 = 6 first Pythagorean triple right triangle */