• API
• FAQ
• Tools
• Archive
SHARE
TWEET # Untitled a guest Feb 27th, 2020 98 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
1. import java.util.Scanner;
2.
3. public class FishingBoat {
4.     public static void main(String[] args) {
5.         Scanner scanner = new Scanner(System.in);
6.         int budget = Integer.parseInt(scanner.nextLine());
7.         String season = scanner.nextLine();
8.         int persons = Integer.parseInt(scanner.nextLine());
9.         double price = 0;
10.
11.         switch (season){
12.             case "Spring":
13.                 if(persons <= 6){
14.                     price = 3000 * 0.9;
15.                 } else if (persons >= 12){
16.                     price = 3000 * 0.75;
17.                 } else {
18.                     price = 3000 * 0.85;
19.                 }
20.                 break;
21.             case "Summer" :
22.             case "Autumn" :
23.                 if(persons <= 6){
24.                     price = 4200 * 0.9;
25.                 } else if (persons >= 12){
26.                     price = 4200 * 0.75;
27.                 } else {
28.                     price = 4200 * 0.85;
29.                 }
30.                 break;
31.             case "Winter":
32.                 if(persons <= 6){
33.                     price = 2600 * 0.9;
34.                 } else if (persons >= 12){
35.                     price = 2600 * 0.75;
36.                 } else {
37.                     price = 2600 * 0.85;
38.                 }
39.                 break;
40.         }  if((!season.equals("Autumn")) && (persons % 2 ==0)){
41.             price = price * 0.95;
42.         }
43.         double deff = Math.abs(budget - price);
44.         if (budget >= price) {
45.             System.out.printf("Yes! You have %.2f leva left.",deff);
46.         } else {
47.             System.out.printf("Not enough money! You need %.2f leva.",deff);
48.         }
49.     }
50. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.
Top