Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- double availableArea = Double.parseDouble(scanner.nextLine());
- int loadedSuitcases = 0;
- String input;
- while (!(input = scanner.nextLine()).equals("End")) {
- double currentSuitcaseArea = Double.parseDouble(input);
- if (++loadedSuitcases % 3 == 0) {
- currentSuitcaseArea *= 1.1;
- }
- if (currentSuitcaseArea > availableArea) {
- System.out.println("No more space!");
- loadedSuitcases--;
- break;
- }
- availableArea -= currentSuitcaseArea;
- }
- if (input.equals("End")) {
- System.out.println("Congratulations! All suitcases are loaded!");
- }
- System.out.println("Statistic: " + loadedSuitcases + " suitcases loaded.");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement