Advertisement
Spocoman

11. Refactor Volume of Pyramid

Oct 17th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.59 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         double length, widht, height;
  7.  
  8.         System.out.print("Length: ");
  9.         length = Double.parseDouble(scanner.nextLine());
  10.         System.out.print("Width: ");
  11.         widht = Double.parseDouble(scanner.nextLine());
  12.         System.out.print("Height: ");
  13.         height = Double.parseDouble(scanner.nextLine());
  14.        
  15.         double volume = (length * widht * height) / 3;
  16.  
  17.         System.out.printf("Pyramid Volume: %.2f", volume);
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement