ISP-JAVA 1. Create two files to submit: • Triangle.java - Class definition • TriangleArea.java - Contains main() method 2. Build the Triangle class with the following specifications: • Private fields o double base - Initialized in default constructor to 0 o double height - Initialized in default constructor to 0 • Default constructor • Public member methods (mutators & accessors) o setBase() o setHeight() o getArea () – To find the area of a triangle, multiply 0.5 * base * height o printInfo – Print the base, height and area with each floating-point value with two digits after the decimal point 3. In main(), create an object of the Triangle class and prompt the user for the base and height values items. Ex: Enter triangle's base: 20 Enter triangle's height: 50 Based on the inputs, the triangle's area is: Base: 20.00 Height: 50.00 Area: 500.00
ISP-JAVA
1. Create two files to submit:
• Triangle.java - Class definition
• TriangleArea.java - Contains main() method
2. Build the Triangle class with the following specifications:
• Private fields
o double base - Initialized in default constructor to 0
o double height - Initialized in default constructor to 0
• Default constructor
• Public member methods (mutators & accessors)
o setBase()
o setHeight()
o getArea () – To find the area of a triangle, multiply 0.5 * base * height
o printInfo – Print the base, height and area with each floating-point value with two digits
after the decimal point
3. In main(), create an object of the Triangle class and prompt the user for the base and height values
items.
Ex:
Enter triangle's base:
20
Enter triangle's height:
50
Based on the inputs, the triangle's area is:
Base: 20.00
Height: 50.00
Area: 500.00
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images