Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package NestedCondStat.Exercises;
- import java.util.Objects;
- import java.util.Scanner;
- public class Fishers {
- public static void main(String[] args) {
- try (Scanner scanner = new Scanner(System.in)) {
- int budget = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine();
- int fishers = Integer.parseInt(scanner.nextLine());
- double rent = 0.0;
- switch (season) {
- case "Spring":
- rent = 3000;
- break;
- case "Summer":
- rent = 4200;
- break;
- case "Autumn":
- rent = 4200;
- break;
- case "Winter":
- rent = 2600;
- break;
- }
- double discount = 0.0;
- if (fishers <= 6) {
- discount = 0.1*rent;
- } else if (fishers >= 7 && fishers <= 11) {
- discount = 0.15*rent;
- } else if (fishers >= 12) {
- discount = 0.25*rent;
- }
- double discount2 = 0.0;
- if (fishers % 2 == 0 && !Objects.equals(season, "Autumn"))
- { discount2 = 0.05*rent;
- }
- double total = rent - (discount + discount2);
- double left = budget-total;
- if(budget>=total){
- System.out.printf("Yes! You have %.2f leva left.", left);
- }else{
- System.out.printf("Not enough money! You need %.2f leva.", total-budget);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement