Advertisement
Valantina

Renovation/Ex/Java

Jul 9th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.11 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P04_Renovation {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int height = Integer.parseInt(scanner.nextLine());
  8.         int width = Integer.parseInt(scanner.nextLine());
  9.         int percent = Integer.parseInt(scanner.nextLine());
  10.  
  11.         int total = height * width * 4;
  12.         double toPaint = Math.ceil(total - total * 1.0 * percent / 100);
  13.  
  14.         String input = scanner.nextLine();
  15.  
  16.         while (!input.equals("Tired!")) {
  17.             int liters = Integer.parseInt(input);
  18.             toPaint -= liters;
  19.             if (toPaint <= 0) {
  20.                 break;
  21.             }
  22.             input = scanner.nextLine();
  23.         }
  24.         if (toPaint == 0) {
  25.             System.out.println("All walls are painted! Great job, Pesho!");
  26.         } else if (toPaint > 0) {
  27.             System.out.println(String.format("%.0f quadratic m left.", toPaint));
  28.         } else {
  29.             System.out.println(String.format("All walls are painted and you have %.0f l paint left!", toPaint * -1));
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement