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