myrdok123

P05Journey

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