Question: Program 2: Triangle 1. Create a Java class named Triangle.java 2. Your program will calculate the area of a triangle using integers. The area of
Program 2: Triangle 1. Create a Java class named Triangle.java 2. Your program will calculate the area of a triangle using integers. The area of a triangle is base height. Prompt the user for the base as an integer, and then prompt for the height (also as an integer). 1. If the user enters any value that is less than or equal to zero for the base or height, your program should not perform any calculations and instead print "Invalid input 2. If both the base and height values from the user are greater than zero, calculate and display the area of the triangle. Sample output is shown below Enter the base: 7 Enter the height: 5 The area of the triangle is: 17.5 The area of the triangle is: 28.0 Enter the base: 7 Enter the height: 8 Enter the base: Enter the height: 4 Invalid input Enter the base: 6 Enter the height: -3 Invalid input
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
