Assignment 1 Solution

Please write a program to calculate the area of a triangle. The area of a triangle can be calculated using the formula:


Area = (base * height) / 2


This program asks the user for the base and height of a triangle, and then prints the area of the triangle.




The user interactively inputs the base and height, as an integer, in meters




The input base and height are echoprinted. Then the area of the triangle is printed as a float number.




·        Base and height units are integers, in meters

·        When asked for a base/height value, the user types in a valid whole number

·        Error checking does not need to be done on these input values


Please download the “” file from Blackboard. You need to correct the errors/bugs in this Java file.


Test case output: (green texts are user input)


Welcome to the Triangle Calculator!


You will be asked to enter the base and height of a triangle, as a whole number, in meters.


Then this program will show you the area of the triangle.




Please enter the height of the triangle -




The height of the triangle in meters (as input): 3 Please enter the base of the triangle -




The base of the triangle in meters (as input): 9

Area of the triangle in meters: 13.5

- Execution Terminated -

 What file to submit on Blackboard


You must turn in your Java program source code only.
Powered by