Advertisement
GabrielHr00

09. Fish Tank

Jan 5th, 2025
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.80 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.  
  7.         int width = Integer.parseInt(scanner.nextLine());
  8.         int height = Integer.parseInt(scanner.nextLine());
  9.         int length = Integer.parseInt(scanner.nextLine());
  10.         double percentToRemove = Double.parseDouble(scanner.nextLine());
  11.  
  12.         //1л = 1дм3 = 1000sm3
  13.         // 1dm = 10sm
  14.         // 1dm3 = 10sm * 10sm * 10sm = 1000sm3
  15.  
  16.         int volumeInSm = width * height * length;
  17.  
  18.         double volumeInLiters = volumeInSm / 1000.0;
  19.         double percentToBeRemoved = volumeInLiters * (percentToRemove/100);
  20.  
  21.         volumeInLiters = volumeInLiters - percentToBeRemoved;
  22.         System.out.println(volumeInLiters);
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement