Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package examPreparation;
- import java.util.Scanner;
- public class P05Renovation {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int height = Integer.parseInt(scanner.nextLine());
- int width = Integer.parseInt(scanner.nextLine());
- int percentWindows = Integer.parseInt(scanner.nextLine());
- double wallsArea = (height * width) * 4;
- double paintArea = Math.ceil(wallsArea - (wallsArea * (percentWindows / 100.0)));
- String input = scanner.nextLine();
- while (!input.equals("Tired!")) {
- int paint = Integer.parseInt(input);
- paintArea = paintArea - paint;
- if (paintArea <= 0) {
- break;
- }
- input = scanner.nextLine();
- }
- if (input.equals("Tired!")) {
- System.out.printf("%.0f quadratic m left.", paintArea);
- } else if (paintArea < 0) {
- System.out.printf("All walls are painted and you have %.0f l paint left!", Math.abs(paintArea));
- } else {
- System.out.println("All walls are painted! Great job, Pesho!");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement