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);
- int budget = Integer.parseInt(scanner.nextLine());
- String season = scanner.nextLine();
- int persons = Integer.parseInt(scanner.nextLine());
- double price = 0;
- switch (season){
- case "Spring":
- if(persons <= 6){
- price = 3000 * 0.9;
- } else if (persons >= 12){
- price = 3000 * 0.75;
- } else {
- price = 3000 * 0.85;
- }
- break;
- case "Summer" :
- case "Autumn" :
- if(persons <= 6){
- price = 4200 * 0.9;
- } else if (persons >= 12){
- price = 4200 * 0.75;
- } else {
- price = 4200 * 0.85;
- }
- break;
- case "Winter":
- if(persons <= 6){
- price = 2600 * 0.9;
- } else if (persons >= 12){
- price = 2600 * 0.75;
- } else {
- price = 2600 * 0.85;
- }
- break;
- } if((!season.equals("Autumn")) && (persons % 2 ==0)){
- price = price * 0.95;
- }
- double deff = Math.abs(budget - price);
- if (budget >= price) {
- System.out.printf("Yes! You have %.2f leva left.",deff);
- } else {
- System.out.printf("Not enough money! You need %.2f leva.",deff);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement