Advertisement
Guest User

Untitled

a guest
Apr 8th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SuitcasesLoad {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         double capasityBagajnik = Double.parseDouble(scanner.nextLine());
  8.         String input = scanner.nextLine();
  9.         int count = 0;
  10.  
  11.         while (!input.equals("End") || capasityBagajnik == 0) {
  12.             double obemKufar = Double.parseDouble(input);
  13.  
  14.             if (count % 3 == 0) {
  15.                 obemKufar = obemKufar + obemKufar * 0.1;
  16.             }
  17.             if (capasityBagajnik > 0) {
  18.                 capasityBagajnik -= obemKufar;
  19.             }
  20.            
  21.             if (capasityBagajnik <= 0) {
  22.                 System.out.println("No more space!");
  23.                 System.out.printf("Statistic: %d suitcases loaded.", count);
  24.                 break;
  25.             }
  26.             count++;
  27.             input = scanner.nextLine();
  28.  
  29.         }
  30.         if (input.equals("End")) {
  31.             System.out.println("Congratulations! All suitcases are loaded!");
  32.             System.out.printf("Statistic: %d suitcases loaded.", count);
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement