Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FishingBoat {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //1. наем -> сезона
- //2. остъпка от наема -> хората
- //3. доп. отстъпка
- //4. бюджетът е достатъчен?
- int budget = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine(); //"Spring", "Summer", "Autumn", "Winter"
- int count = Integer.parseInt(scanner.nextLine());
- double rent = 0; //наем
- //сезона
- switch (season) {
- case "Spring":
- rent = 3000;
- break;
- case "Summer":
- case "Autumn":
- rent = 4200;
- break;
- case "Winter":
- rent = 2600;
- break;
- }
- //хората
- if (count <= 6) {
- rent = rent - 0.10 * rent;
- //rent = 0.9 * rent
- //rent -= 0.10 * rent
- } else if (count >= 7 && count <= 11) { //[7 до 11]
- rent = rent - 0.15 * rent;
- //rent = 0.85 * rent
- //rent -= 0.15 * rent
- } else if (count >= 12) {
- rent = rent - 0.25 * rent;
- //rent = 0.75 * rent
- //rent -= 0.25 * rent
- }
- //четен брой и не е есен
- if (count % 2 == 0 && !season.equals("Autumn")) {
- rent = rent - 0.05 * rent;
- //rent = 0.95 * rent
- //rent -= 0.05 * rent
- }
- //достатъчен
- if (budget >= rent) {
- double leftMoney = budget - rent;
- System.out.printf("Yes! You have %.2f leva left.", leftMoney);
- } else { //budget < rent
- double needMoney = rent - budget;
- System.out.printf("Not enough money! You need %.2f leva.", needMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement