valiamaximova1

Plane suites java

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