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