Advertisement
psi_mmobile

Untitled

May 21st, 2022
1,233
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.29 KB | None | 0 0
  1. public class MyClass {
  2.     public static void main(String args[]) {
  3.         java.util.Scanner scanner = new java.util.Scanner(System.in);
  4.         int dishCount = 0;
  5.         int potCount = 0;
  6.        
  7.         int wholeDetergent = scanner.nextInt();
  8.         wholeDetergent = wholeDetergent * 750;
  9.        
  10.         String input = "";
  11.         int loading = 1;
  12.         while(wholeDetergent >= 0) {
  13.             input = scanner.next();
  14.             if (input.equals("End")) {
  15.                 break;
  16.             } else {
  17.                 if (loading % 3 == 0) {
  18.                     potCount += Integer.parseInt(input);
  19.                     wholeDetergent -= Integer.parseInt(input) * 15;
  20.                 } else {
  21.                     dishCount += Integer.parseInt(input);
  22.                     wholeDetergent -= Integer.parseInt(input) * 5;
  23.                 }
  24.             }
  25.             loading++;
  26.         }
  27.         if (wholeDetergent < 0) {
  28.             System.out.printf("Not enough detergent, %d ml. more necessary!", Math.abs(wholeDetergent));
  29.         } else {
  30.             System.out.println("Detergent was enough!");
  31.             System.out.printf("%d dishes and %d pots were washed.\n",dishCount, potCount);
  32.             System.out.printf("Leftover detergent %d ml.", wholeDetergent);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement