Hello, I have tried everything and my code won't do what it needs to can someone explain this to me D:!?
Write a Java program that computes the area of a scalene triangle. Use the input dialog box to get the sides a, b, and c of the scalene triangle and compute the area using the following equation;
Area = (s (s – a) (s - b) (s – c) )1/2 where s=(a+b+c)/2
Your program must check that none of the length of the sides (a,b,c) is <= 0 and s > a and s > b and s > c. The output must be displayed in the message dialog box. (hint: you may use math class methods if needed).
and heres what I have....
import javax.swing.JOptionPane;
public class Assignment3
{
public static void main(String[] args)
{
double sideA;
double sideB;
double sideC;
double s;
double Area;
String input;
input =
JOptionPane.showInputDialog("Enter side A"); //input box for side A
sideA = Double.parseDouble (input);
input =
JOptionPane.showInputDialog("Enter side B"); //input box for side B
sideB = Double.parseDouble (input);
input =
JOptionPane.showInputDialog("Enter side C"); //input box for side C
sideC = Double.parseDouble (input);
s = (sideA + sideB + sideC) / 2; //finds what s is = to
JOptionPane.showMessageDialog (null, "s is equal to " + s);
Area = Math.pow (s*(s - sideA)*(s - sideB)*(s - sideC),1/2); //finds the area
JOptionPane.showMessageDialog (null,"Area is equal to " + Area);
//checks to see the each side is less then or equal to 0
if (sideA <= 0)
JOptionPane.showMessageDialog (null, " A is less then 0");
if (sideB <= 0)
JOptionPane.showMessageDialog (null, " B is less then 0");
if (sideC <= 0)
JOptionPane.showMessageDialog (null, "C is less then 0");
System.exit(0);
}
}