Given class Triangle , complete main() to read and set the base and height of triangle1 and of triangle2, determine which triangle's area is smaller, and output that triangle's info, making use of Triangle's relevant methods.
JAVA
Given class Triangle , complete main() to read and set the base and height of triangle1 and of triangle2, determine which triangle's area is smaller, and output that triangle's info, making use of Triangle's relevant methods.
/****************************************************************
import java.util.Scanner;
class TriangleArea {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
**************************************************************************************/
finish code in Java.
The below program uses class Triangle to compare the area between two triangles and outputs which triangle has the smaller area. The user is prompted to input the base and height for both triangles. Objects of type Triangle are then created, and the areas of both triangles are calculated. An if-else statement is used to compare the two areas and output the smaller triangle's info.
Step by step
Solved in 4 steps with 2 images