Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // Instantiate TriPrism objects with Integer and Double types
- TriPrism<Integer> tp1 = new TriPrism<>();
- TriPrism<Double> tp2 = new TriPrism<>();
- System.out.println("Triangular Prism 1");
- // User input for the setter
- System.out.print("Length: ");
- tp1.setLength(10);
- System.out.print("Base: ");
- tp1.setBase(7);
- System.out.print("Height: ");
- tp1.setHeight(5);
- System.out.println("The volume of the triangular prism is " + tp1.calculateVolume());
- System.out.println("Triangular Prism 2");
- System.out.print("Length: ");
- tp2.setLength(9.10);
- System.out.print("Base: ");
- tp2.setBase(6.25);
- System.out.print("Height: ");
- tp2.setHeight(4.20);
- System.out.println("The volume of the triangular prism is " + tp2.calculateVolume());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment