school/lab-9/triangle-area/TriangleArea.java
2020-11-11 08:47:37 -05:00

29 lines
900 B
Java

import java.util.Scanner;
public class TriangleArea {
public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
Triangle triangle1 = new Triangle();
Triangle triangle2 = new Triangle();
// TODO: Read and set base and height for triangle1 (use setBase() and setHeight())
triangle1.setBase(scnr.nextDouble());
triangle1.setHeight(scnr.nextDouble());
// TODO: Read and set base and height for triangle2 (use setBase() and setHeight())
triangle2.setBase(scnr.nextDouble());
triangle2.setHeight(scnr.nextDouble());
// TODO: Determine larger triangle (use getArea())
Triangle largest = (triangle1.getArea() > triangle2.getArea()) ? triangle1:triangle2;
System.out.println("Triangle with larger area:");
// TODO: Output larger triangle's info (use printInfo())
largest.printInfo();
}
}