SenpaiZero

Main

Jun 5th, 2024
950
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.        
  6.         Scanner scanner = new Scanner(System.in);
  7.         // Instantiate TriPrism objects with Integer and Double types
  8.         TriPrism<Integer> tp1 = new TriPrism<>();
  9.         TriPrism<Double> tp2 = new TriPrism<>();
  10.  
  11.         System.out.println("Triangular Prism 1");
  12.         // User input for the setter
  13.         System.out.print("Length: ");
  14.         tp1.setLength(10);
  15.         System.out.print("Base: ");
  16.         tp1.setBase(7);
  17.         System.out.print("Height: ");
  18.         tp1.setHeight(5);
  19.         System.out.println("The volume of the triangular prism is " + tp1.calculateVolume());
  20.  
  21.         System.out.println("Triangular Prism 2");
  22.         System.out.print("Length: ");
  23.         tp2.setLength(9.10);
  24.         System.out.print("Base: ");
  25.         tp2.setBase(6.25);
  26.         System.out.print("Height: ");
  27.         tp2.setHeight(4.20);
  28.         System.out.println("The volume of the triangular prism is " + tp2.calculateVolume());
  29.     }
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment