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 scanner = new Scanner(System.in);
- // Spring - 3000 Summer and Autumn - 4200; Winter - 2600
- int budget = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine();
- int number = Integer.parseInt(scanner.nextLine());
- double price = 0;
- // <= 6 - 10% 7-11 - 15%; 12>= 25%
- if (season.equals("Spring")){
- price = 3000;
- }else if (season.equals("Summer") || season.equals("Autumn")){
- price = 4200;
- }else if (season.equals("Winter")){
- price = 2600;
- }
- double totalPrice = 0;
- if (number <=6){
- totalPrice = price * 0.9;
- }else if (number > 7 && number <= 11){
- totalPrice = price * 0.85;
- }else if (number >= 12){
- totalPrice = price * 0.75;
- }
- if (number %2 ==0){
- if (season.equals("Spring") || season.equals("Summer") || season.equals("Winter")){
- totalPrice = totalPrice * 0.95;
- }
- }
- if (budget >= totalPrice){
- double leftMoney = budget - totalPrice;
- System.out.printf("Yes! You have %.2f leva left.", leftMoney);
- }else {
- double needMoney = totalPrice - budget;
- System.out.printf("Not enough money! You need %.2f leva.", needMoney);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement