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