SHOW:
|
|
- or go back to the newest paste.
1 | import java.util.Scanner; | |
2 | ||
3 | - | public class FishingBoat { |
3 | + | public class Test5SuitcasesLoad { |
4 | public static void main(String[] args) { | |
5 | - | Scanner scanner = new Scanner(System.in); |
5 | + | Scanner scan = new Scanner(System.in); |
6 | - | double budget = Double.parseDouble(scanner.nextLine()); |
6 | + | |
7 | - | String seasson = scanner.nextLine(); |
7 | + | double capacity = Double.parseDouble(scan.nextLine()); |
8 | - | int fishersNum = Integer.parseInt(scanner.nextLine()); |
8 | + | String restriction = scan.nextLine(); |
9 | - | double price = 0.0; |
9 | + | int counter = 0; |
10 | ||
11 | while (!restriction.equals("End")) { | |
12 | - | if (seasson.equals("Spring")) { |
12 | + | double volume = Double.parseDouble(restriction); |
13 | - | price = 3000; |
13 | + | counter++; |
14 | - | } else if (seasson.equals("Summer") || seasson.equals("Autumn")) { |
14 | + | if (counter % 3 == 0) { |
15 | - | price = 4200; |
15 | + | volume = volume * 1.1; |
16 | - | } else if (seasson.equals("Winter")) { |
16 | + | } |
17 | - | price = 2600; |
17 | + | if (volume > capacity) { |
18 | System.out.println("No more space!"); | |
19 | - | if (fishersNum <= 6) { |
19 | + | System.out.printf("Statistic: %d suitcases loaded.", counter - 1); |
20 | - | price *= 0.9; |
20 | + | return; |
21 | } | |
22 | - | } else if (fishersNum > 7 && fishersNum <= 11) { |
22 | + | capacity = capacity - volume; |
23 | - | price *= 0.85; |
23 | + | restriction = scan.nextLine(); |
24 | - | } else if (fishersNum >= 12) { |
24 | + | |
25 | - | price *= 0.75; |
25 | + | System.out.println("Congratulations! All suitcases are loaded!"); |
26 | System.out.printf("Statistic: %d suitcases loaded.", counter); | |
27 | - | if (fishersNum % 2 == 0 && !(seasson.equals("Autumn")) ) { |
27 | + | |
28 | - | price *= 0.95; |
28 | + |