Advertisement
psi_mmobile

Untitled

May 28th, 2022
1,106
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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.         }
  25.         if (totalSpace < 0) {
  26.             System.out.printf("All walls are painted and you have %.0f l paint left!", Math.abs(totalSpace));
  27.         }
  28.         if (totalSpace == 0) {
  29.             System.out.print("All walls are painted! Great job, Pesho!");
  30.         }
  31.     }
  32. }
Advertisement
RAW Paste Data Copied
Advertisement