desislava_topuzakova

2. Пътешествие

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