Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FishingBoat_05 {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int budget = Integer.parseInt(scan.nextLine());
- String season = scan.nextLine();
- int fishermans = Integer.parseInt(scan.nextLine());
- double rent = 0.0;
- switch (season) {
- case "Spring":
- rent = 3000;
- break;
- case "Summer":
- case "Autumn":
- rent = 4200;
- break;
- case "Winter":
- rent = 2600;
- break;
- }
- //• Ако групата е до 6 човека включително – отстъпка от 10%.
- //• Ако групата е от 7 до 11 човека включително – отстъпка от 15%.
- //• Ако групата е от 12 нагоре – отстъпка от 25%.
- //Рибарите ползват допълнително 5% отстъпка ако са четен брой освен ако не е есен - тогава нямат допълнителна отстъпка.
- if (fishermans <= 6) {
- rent = rent - 0.10 * rent;
- } else if (fishermans <= 11) {
- rent = rent - 0.15 * rent;
- } else if (fishermans > 12) {
- rent = rent - 0.25 * rent;
- }
- if (fishermans % 2 == 0 && !season.equals("Autumn")) {
- rent = rent - 0.05;
- }
- if (budget >= rent) {
- double moneyLeft = budget - rent;
- System.out.printf("Yes! You have %.2f leva left.", moneyLeft);
- } else if (budget < rent) {
- double moneyNeed = rent - budget;
- System.out.printf("Not enough money! You need %.2f leva.", moneyNeed);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement