keith
_______________________________
error:
TriangleMeasurementsDialogBox.java:39: cannot find symbol
symbol : method showMessageDialog(<nulltype>,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, outputStr, JOptionPane.INFORMATION_MESSAGE);
^
1 error
----jGRASP wedge2: exit code for process is 1.
----jGRASP: operation complete.
__________________________________
import java.util.*;
import javax.swing.JOptionPane;
import static java.lang.Math.*;
public class TriangleMeasurementsDialogBox
{
public static void main (String [] args)
{ double num1, num2, num3; //Sides of triangle
double x; //Perimeter of tringle variable
double area; //Area of a triangle
String sidesStr;
String outputStr;
//Input the three numbers in dialog box
sidesStr =
JOptionPane.showInputDialog("Enter the lengths of three sides of a triangle seperated by spaces: ");
//Determine the perimeter
x = num1 + num2 + num3;
//Determine the area
area = sqrt((x/2) * (x/2 - num1) * (x/2 - num2) * (x/2 - num3));
//Out put the sides, perimeter and area in dialog box
outputStr = "Sides: " + num1 + num2 + num3 +
"Perimeter: " + x + "units" +
"Area: " + area + "square units";
JOptionPane.showMessageDialog(null, outputStr, JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}

New Topic/Question
Reply




MultiQuote





|