Advertisement
psi_mmobile

Untitled

May 28th, 2022
1,533
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.03 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         int height = Integer.parseInt(scanner.nextLine());
  5.         int width = Integer.parseInt(scanner.nextLine());
  6.         int skipPercent = Integer.parseInt(scanner.nextLine());
  7.        
  8.         double totalSpace = height * width * 4;
  9.         totalSpace = Math.ceil(totalSpace - (totalSpace * skipPercent) / 100.0);
  10.        
  11.         while (true) {
  12.             String input = scanner.nextLine();
  13.             if (input.equals("Tired!")) {
  14.                 break;
  15.             } else {
  16.                 totalSpace -= Integer.parseInt(input);
  17.                 if (totalSpace <= 0) {
  18.                     break;
  19.                 }
  20.             }
  21.         }
  22.         if (totalSpace > 0) {
  23.             System.out.printf("%.0f quadratic m left.",totalSpace);
  24.         } else {
  25.             System.out.printf("All walls are painted and you have %.0f l paint left!", Math.abs(totalSpace));
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement