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