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

EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter11: Advanced Inheritance Concepts
Section: Chapter Questions
Problem 3PE
icon
Related questions
Question

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 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Development strategies
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT