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