Advertisement
GabrielHr00

09. Fish Tank

May 14th, 2023
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FishTank {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int width = Integer.parseInt(scanner.nextLine());
  7.         int height = Integer.parseInt(scanner.nextLine());
  8.         int length = Integer.parseInt(scanner.nextLine());
  9.         double percent = Double.parseDouble(scanner.nextLine());
  10.  
  11.         int volumeInSm = width * height * length;
  12.         // 10sm = 1dm        ->    1dm3 = 10sm ^3 (10sm * 10sm * 10sm = 1000sm)
  13.         // 1dm3 = 1000sm3
  14.  
  15.         double volumeInLiters = volumeInSm / 1000.0;
  16.         double volumeWithoutPercent = volumeInLiters - (volumeInLiters * percent/100);
  17.  
  18.         System.out.println(volumeWithoutPercent);
  19.     }
  20. }
  21.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement