Advertisement
veronikaaa86

04. Renovation

Aug 14th, 2021
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. package examPreparation;
  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 height = Integer.parseInt(scanner.nextLine());
  10. int width = Integer.parseInt(scanner.nextLine());
  11. int percentWindows = Integer.parseInt(scanner.nextLine());
  12.  
  13. double wallsArea = (height * width) * 4;
  14. double paintArea = Math.ceil(wallsArea - (wallsArea * (percentWindows / 100.0)));
  15.  
  16. String input = scanner.nextLine();
  17. while (!input.equals("Tired!")) {
  18. int paint = Integer.parseInt(input);
  19.  
  20. paintArea = paintArea - paint;
  21.  
  22. if (paintArea <= 0) {
  23. break;
  24. }
  25.  
  26. input = scanner.nextLine();
  27. }
  28.  
  29. if (input.equals("Tired!")) {
  30. System.out.printf("%.0f quadratic m left.", paintArea);
  31. } else if (paintArea < 0) {
  32. System.out.printf("All walls are painted and you have %.0f l paint left!", Math.abs(paintArea));
  33. } else {
  34. System.out.println("All walls are painted! Great job, Pesho!");
  35. }
  36.  
  37.  
  38. }
  39. }
  40.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement