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 scan = new Scanner(System.in);
- double budget = Double.parseDouble(scan.nextLine());
- String season = scan.nextLine();
- int fishermen = Integer.parseInt(scan.nextLine());
- double boatPrice = 0.0;
- double discount = 0.0;
- double totalPrice =0.0;
- switch (season) {
- case "Spring":
- boatPrice = 3000;
- if (fishermen <= 6) {
- if (fishermen % 2 == 0) {
- discount = 0.15;
- } else {
- discount = 0.1;
- }
- } else if (fishermen >= 7 && fishermen <= 11) {
- if (fishermen % 2 == 0) {
- discount = 0.2;
- } else {
- discount = 0.15;
- }
- } else if (fishermen >= 12) {
- if (fishermen % 2 == 0) {
- discount = 0.3;
- } else {
- discount = 0.25;
- }
- }
- break;
- case "Summer":
- boatPrice = 4200;
- if (fishermen <= 6) {
- if (fishermen % 2 == 0) {
- discount = 0.15;
- } else {
- discount = 0.1;
- }
- } else if (fishermen >= 7 && fishermen <= 11) {
- if (fishermen % 2 == 0) {
- discount = 0.2;
- } else {
- discount = 0.15;
- }
- } else if (fishermen >= 12) {
- if (fishermen % 2 == 0) {
- discount = 0.3;
- } else {
- discount = 0.25;
- }
- }
- break;
- case "Autumn":
- boatPrice = 4200;
- if (fishermen <= 6) {
- discount = 0.1;
- } else if (fishermen >= 7 && fishermen <= 11) {
- discount = 0.15;
- } else if (fishermen >= 12) {
- discount = 0.25;
- }
- break;
- case "Winter":
- boatPrice = 2600;
- if (fishermen <= 6) {
- if (fishermen % 2 == 0) {
- discount = 0.15;
- } else {
- discount = 0.1;
- }
- } else if (fishermen >= 7 && fishermen <= 11) {
- if (fishermen % 2 == 0) {
- discount = 0.2;
- } else {
- discount = 0.15;
- }
- } else if (fishermen >= 12) {
- if (fishermen % 2 == 0) {
- discount = 0.3;
- } else {
- discount = 0.25;
- }
- }
- break;
- }
- totalPrice = boatPrice - boatPrice * discount;
- if (budget >= totalPrice) {
- System.out.printf("Yes! You have %.2f leva left.", Math.abs(budget - totalPrice));
- } else if (budget < totalPrice) {
- System.out.printf("Not enough money! You need %.2f leva.", Math.abs(budget-totalPrice));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement