Advertisement
veronikaaa86

03. Travel Agency

Feb 18th, 2023
827
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.00 KB | None | 0 0
  1. package examPrep;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P03TravelAgency {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String town = scanner.nextLine();
  10.         String typePackage = scanner.nextLine();
  11.         String VIP = scanner.nextLine();
  12.         int days = Integer.parseInt(scanner.nextLine());
  13.  
  14.         //("noEquipment",  "withEquipment", "noBreakfast" или "withBreakfast")
  15.  
  16.         boolean isValid = true;
  17.         double price = 0;
  18.         if (town.equals("Bansko") || town.equals("Borovets")) {
  19.             if (typePackage.equals("noEquipment")) {
  20.                 price = 80;
  21.                 if (VIP.equals("yes")) {
  22.                     price = price * 0.95;
  23.                 }
  24.             } else if (typePackage.equals("withEquipment")) {
  25.                 price = 100;
  26.                 if (VIP.equals("yes")) {
  27.                     price = price * 0.90;
  28.                 }
  29.             } else {
  30.                 isValid = false;
  31.             }
  32.         } else if (town.equals("Varna") || town.equals("Burgas")) {
  33.             if (typePackage.equals("noBreakfast")) {
  34.                 price = 100;
  35.                 if (VIP.equals("yes")) {
  36.                     price = price * 0.93;
  37.                 }
  38.             } else if (typePackage.equals("withBreakfast")) {
  39.                 price = 130;
  40.                 if (VIP.equals("yes")) {
  41.                     price = price * 0.88;
  42.                 }
  43.             } else {
  44.                 isValid = false;
  45.             }
  46.         } else {
  47.             isValid = false;
  48.         }
  49.  
  50.         if (days < 1) {
  51.             System.out.println("Days must be positive number!");
  52.         } else if (!isValid) {
  53.             System.out.println("Invalid input!");
  54.         } else {
  55.             if (days > 7) {
  56.                 days = days - 1;
  57.             }
  58.  
  59.             double totalPrice = price * days;
  60.             System.out.printf("The price is %.2flv! Have a nice time!", totalPrice);
  61.         }
  62.     }
  63. }
  64.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement