|
Corrections
Hi,
Try running the following code, I think it would solve all your problems
import javax.swing.*;
public class Pythagoras2 {
public static void main (String[] arg) {
String s;
s = JOptionPane.showInputDialog ("First side?");
double a = Double.parseDouble(s);
s = JOptionPane.showInputDialog ("Second side?");
double b = Double.parseDouble(s);
double c = Math.sqrt(a*a + b*b);
double area = (a*b/2);
JOptionPane.showMessageDialog(null,
"Hypotenusans length: " + c + "\nArea:" + area);
System.exit(0);
}
}
The first problem with your code was that you were trying to find the modulus (remainder) where you are supposed to divide.
You need to put in escape sequence characters to change the lines in the Message dialogs the same way that you need them when displaying the output on console.
Hope this solves the problem,
Regards
Ali
|