Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FishingBoat_04 {
- 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 boatPrice = 0;
- double discount = 0;
- switch (season) {
- case "Spring":
- boatPrice = 3000;
- break;
- case "Summer":
- case "Autumn":
- boatPrice = 4200;
- break;
- case "Winter":
- boatPrice = 2600;
- break;
- }
- if (fishersCount <= 6) {
- discount = 0.1 * boatPrice;
- } else if (fishersCount >= 7 && fishersCount <= 11) {
- discount = 0.15 * boatPrice;
- } else if (fishersCount > 11) {
- discount = 0.25 * boatPrice;
- }
- if(fishersCount % 2 == 0 && !season.equals("Autumn")){
- discount += 0.05 * boatPrice;
- }
- boatPrice -= discount;
- if(budget >= boatPrice){
- double moneyLeft = budget - boatPrice;
- System.out.printf("Yes! You have %.2f leva left.", moneyLeft);
- } else {
- double moneyLack = boatPrice - budget;
- System.out.printf("Not enough money! You need %.2f leva.", moneyLack);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement