Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.util.Scanner;
- public class Y06fishingBoat {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int budget = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine();
- int countFisherman = Integer.parseInt(scanner.nextLine());
- int priceSpring = 3000;
- int priceSummerAutumn = 4200;
- int priceWinter = 2600;
- double priceForSeason = 0;
- switch (season.toLowerCase()) {
- case "spring":
- priceForSeason = priceSpring;
- break;
- case "summer":
- case "autumn":
- priceForSeason = priceSummerAutumn;
- break;
- case "winter":
- priceForSeason = priceWinter;
- break;
- }
- int discount = 0;
- if (countFisherman <= 6) {
- discount = 10;
- } else if (countFisherman <= 11) {
- discount = 15;
- } else {
- discount = 25;
- }
- double priceWithDiscount =
- priceForSeason - priceForSeason * discount / 100.0;
- int additionalDiscount = 0;
- if (countFisherman % 2 == 0 && !"autumn".equalsIgnoreCase(season)) {
- additionalDiscount = 5;
- }
- double finalPriceWithDiscount =
- priceWithDiscount - priceWithDiscount * additionalDiscount / 100.0;
- double diff = budget - finalPriceWithDiscount;
- if (budget >= finalPriceWithDiscount) {
- System.out.printf("Yes! You have %.2f leva left.", diff);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(diff));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment