Advertisement
valiamaximova1

Suitcases Load

Apr 23rd, 2020
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.19 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SuitcasesLoad {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.         double capacity = Double.parseDouble(scan.nextLine());
  7.         boolean isFull = false;
  8.         int couter =0;
  9.         int counterSutecase =0;
  10.  
  11.         String input = scan.nextLine();
  12.         while (!"End".equals(input)){
  13.             double suitcase = Double.parseDouble(input);
  14.             couter++;
  15.             if(couter % 3 == 0){
  16.                 suitcase = suitcase * 1.1;
  17.             }
  18.  
  19.             if(capacity >= suitcase){
  20.                 capacity -= suitcase;
  21.                 counterSutecase++;
  22.             }else{
  23.                 isFull = true;
  24.                 break;
  25.             }
  26.  
  27.             if(capacity > 0){
  28.                 input = scan.nextLine();
  29.             }else{
  30.                 isFull = true;
  31.                 break;
  32.             }
  33.  
  34.         }
  35.         if(isFull){
  36.             System.out.println("No more space!");
  37.         }else{
  38.             System.out.println("Congratulations! All suitcases are loaded!");
  39.         }
  40.         System.out.printf("Statistic: %d suitcases loaded.", counterSutecase );
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement