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