Program for calculating area and hypotenus in a triangel
Hi!
I try to make a program on this conditions:
Make a program where I can put in the values for the 2 cathetus in an right angled triangel the the program will calculate the hypotenusa and area.
I have managed the hypotenusa but are stuck on the area I get Area 0.0.
I also have probelms with the last showMeessageDialog I want the Area to be on a new line there.
The program looks like this:
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 + "Area:" + area);
System.exit(0);
}
}
????? I´m lost
Legoland