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