Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package _03_ConditionalStatementsAdvanced;
- import java.util.Scanner;
- public class FishingBoat {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int budget = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine();
- int fishersCount = Integer.parseInt(scanner.nextLine());
- double boatRent = 0.0;
- switch (season) {
- case "Spring":
- boatRent = 3000.0;
- break;
- case "Summer":
- case "Autumn":
- boatRent = 4200.0;
- break;
- case "Winter":
- boatRent = 2600.0;
- break;
- }
- if (fishersCount <= 6) {
- boatRent = boatRent * 0.90;
- } else if (fishersCount >= 7 && fishersCount <= 11) {
- boatRent = boatRent * 0.85;
- } else if (fishersCount >= 12) {
- boatRent = boatRent * 0.75;
- }
- if (fishersCount % 2 == 0 && !(season.equals("Autumn")) ) {
- boatRent = boatRent * 0.95;
- }
- double diff = Math.abs(budget - boatRent);
- if (budget >= boatRent) {
- System.out.printf("Yes! You have %.2f leva left.", diff);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", diff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement