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