school/lab-9/triangle-area/Triangle.java

23 lines
504 B
Java
Raw Normal View History

2020-11-11 08:47:37 -05:00
public class Triangle {
private double base;
private double height;
public void setBase(double userBase){
base = userBase;
}
public void setHeight(double userHeight) {
height = userHeight;
}
public double getArea() {
double area = 0.5 * base * height;
return area;
}
public void printInfo() {
System.out.printf("Base: %.2f\n", base);
System.out.printf("Height: %.2f\n", height);
System.out.printf("Area: %.2f\n", getArea());
}
}