Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Dishwasher {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int detergentMl = Integer.parseInt(scanner.nextLine()) * 750;
- int counter = 1, dishes = 0, pots = 0, charging;
- String input = "";
- while (detergentMl >= 0 && !(input = scanner.nextLine()).equals("End")) {
- charging = Integer.parseInt(input);
- if (counter % 3 != 0) {
- dishes += charging;
- detergentMl -= charging * 5;
- } else {
- pots += charging;
- detergentMl -= charging * 15;
- }
- counter++;
- }
- if (input.equals("End")) {
- System.out.println("Detergent was enough!");
- System.out.printf("%d dishes and %d pots were washed.\n", dishes, pots);
- System.out.printf("Leftover detergent %d ml.", detergentMl);
- } else {
- System.out.printf("Not enough detergent, %d ml. more necessary!", Math.abs(detergentMl));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement