myrdok123

05. Journey

May 14th, 2023
876
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.15 KB | None | 0 0
  1. package L03_ConditionalStatementsAdvanced;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05_Journey {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.  
  11.         double budget = Double.parseDouble(scanner.nextLine());
  12.         String season = scanner.nextLine();
  13.  
  14.         //създаваме променливи, в които да запазим: къде ще почива, какъв тип ще бъде настаняването, колко е изхарчил
  15.  
  16.         String destination = "";
  17.         String accommodationType = "";
  18.         double spendMoney = 0;
  19.  
  20.         //правим проверка за бюджета -> <=100 България, <= 1000 Балканите, всички останали случаи -> Европа
  21.         //проверяваме къде ще почива и кой е сезона
  22.         if(budget <= 100 && season.equals("summer")){
  23.             destination = "Bulgaria";
  24.             accommodationType = "Camp";
  25.             spendMoney = budget * 0.3;
  26.            
  27.            /* if(season.equals("summer")){
  28.                 accommodationType = "Camp";
  29.                 spendMoney = budget * 0.3;
  30.             }else {
  31.                 accommodationType = "Hotel";
  32.                 spendMoney = budget * 0.7;
  33.             }*/
  34.  
  35.         }else if(budget <= 100 && season.equals("winter")){
  36.             destination = "Bulgaria";
  37.             accommodationType = "Hotel";
  38.             spendMoney = budget * 0.7;
  39.         } else if (budget <= 1000 && season.equals("summer")) {
  40.             destination = "Balkans";
  41.             accommodationType = "Camp";
  42.             spendMoney = budget * 0.4;
  43.         } else if (budget <= 1000 && season.equals("winter")) {
  44.  
  45.             destination = "Balkans";
  46.             accommodationType = "Hotel";
  47.             spendMoney = budget * 0.8;
  48.         }else {
  49.             destination = "Europe";
  50.             accommodationType = "Hotel";
  51.             spendMoney = budget * 0.9;
  52.         }
  53.  
  54.         System.out.printf("Somewhere in %s%n", destination);
  55.         System.out.printf("%s - %.2f", accommodationType, spendMoney);
  56.  
  57.  
  58.     }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment