I have to mplement a static-public method named "trapezoidArea" in the class "Functionality.java", which should calculate the area of a trapezoid. The method gets as input parameters the two parallel sides a and c; and the height h as integer values. The method returns a double value.trapezoidArea(a : int, c : int, h : int) : double. I also have to pay attention to the early data type conversion (casting). If at least one of the input values is <= 0, -1.0 should be returned.
So this is the code: But its not working
public class Functionality {
public static double trapezoidArea(int a, int c, int h) {
double input = 0;
if (input <= 0) {
input = 0.5 * (a + c) * h;
return input;
} else if (a <= 0 || c <= 0 || h <= 0) {
return -1.0;
}
return input;
}
Aucun commentaire:
Enregistrer un commentaire