Question: Create a generic class called TriPrism. It shall store the dimensions of a triangular prism and calculate its volume. The type of the dimensions

Create a generic class called TriPrism. It shall store the dimensions of a triangular prism and calculate its volume. The type of the dimensions will be decided upon instantiation of the TriPrism objects. Use the formula: volume = length * (0.5 * base * height) 1. Create a generic class called TriPism! 2. Declare three (3) private variables named length, base, and height. 3. Add three (3) pairs of getters and setters to retrieve and set the values of the variables mentioned above. 4. Create another class named TriPrismDemo. 5. In its main method, instantiate two (2) TriPrism objects named tp1 (Integer) and tp2 (Double). 6. Use the setter methods to set the values of the dimensions. 7. Calculate and display the volume of the two (2) TriPrism objects using the getter methods. Refer to the formula provided above. Sample Output: Triangular Prism 1 Length: 10 Base: 7 Height: 5 The volume of the triangular prism is 175.0. Triangular Prism 2 Length: 9.10 Base: 6.25 Height: 4.20 The volume of the triangular prism is 119.4375.
Step by Step Solution
There are 3 Steps involved in it
Introducing the concept The task involves creating a generic Java class named TriPrism to represent a triangular prism and calculate its volume The class is designed to store dimensions length base an... View full answer
Get step-by-step solutions from verified subject matter experts
