Advertisement
veronikaaa86

04. Renovation

Aug 13th, 2022 (edited)
1,108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.14 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05Renovation {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         int h = Integer.parseInt(scanner.nextLine());
  10.         int w = Integer.parseInt(scanner.nextLine());
  11.         int percentUnpainted = Integer.parseInt(scanner.nextLine());
  12.  
  13.         double area = Math.ceil(h * w * 4);
  14.         double areaPainted = area * (1 - percentUnpainted / 100.0);
  15.  
  16.         String input = scanner.nextLine();
  17.         while (!input.equals("Tired!")) {
  18.             int paint = Integer.parseInt(input);
  19.  
  20.             areaPainted = areaPainted - paint;
  21.  
  22.             if (areaPainted <= 0) {
  23.                 break;
  24.             }
  25.  
  26.             input = scanner.nextLine();
  27.         }
  28.  
  29.         if (areaPainted == 0) {
  30.             System.out.println("All walls are painted! Great job, Pesho!");
  31.         }else if (areaPainted > 0) {
  32.             System.out.printf("%.0f quadratic m left.", areaPainted);
  33.         } else {
  34.             System.out.printf("All walls are painted and you have %.0f l paint left!", Math.abs(areaPainted));
  35.         }
  36.     }
  37. }
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement