Facebook
From Beige Tapir, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 55
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class TravelAgency {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.  
  9.         String town = scanner.nextLine();
  10.         String packet = scanner.nextLine();
  11.         String card = scanner.nextLine();
  12.         int countDays = Integer.parseInt(scanner.nextLine());
  13.         double price = 0;
  14.  
  15.         if ("Bansko".equals(town) || "Borovets".equals(town)) {
  16.             if (packet.equals("withEquipment")) {
  17.                 price = 100;
  18.             } else if (packet.equals("noEquipment")) {
  19.                 price = 80;
  20.             }
  21.  
  22.         } else if ("Varna".equals(town) || "Burgas".equals(town)) {
  23.             if (packet.equals("withBreakfast")) {
  24.                 price = 130;
  25.             } else if (packet.equals("noBreakfast")) {
  26.                 price = 100;
  27.             }
  28.         }
  29.  
  30.         if (card.equals("yes")) {
  31.             if (packet.equals("withEquipment")) {
  32.                 price = 100 - 100 * 0.01;
  33.             } else if (packet.equals("noEquipment")) {
  34.                 price = 80 - 80 * 0.05;
  35.             } else if (packet.equals("withBreakfast")) {
  36.                 price = 130 - 130 * 0.12;
  37.             } else if (packet.equals("noBreakfast")) {
  38.                 price = 100 - 100 * 0.07;
  39.             }
  40.         }
  41.  
  42.         if (countDays > 7) {
  43.             countDays = countDays - 1;
  44.         }
  45.         price = countDays * price;
  46.  
  47.         if ("Bansko".equals(town) || "Borovets".equals(town) || "Varna".equals(town) || "Burgas".equals(town)) {
  48.             if (packet.equals("withEquipment") || packet.equals("noEquipment") || packet.equals("withBreakfast") || packet.equals("noBreakfast")) {
  49.                 if (countDays > 1) {
  50.                     System.out.printf("The price is %.2flv! Have a nice time!", price);
  51.                 }
  52.             }
  53.         }
  54.         if (countDays < 1) {
  55.             System.out.println("Days must be positive number!");
  56.         }
  57.  
  58.         if ((!("Bansko".equals(town) || "Borovets".equals(town) || "Varna".equals(town) || "Burgas".equals(town))) || (!(packet.equals("withEquipment") || packet.equals("noEquipment") || packet.equals("withBreakfast") || packet.equals("noBreakfast")))) {
  59.                 System.out.println("Invalid input!");
  60.             }
  61.  
  62.  
  63.     }
  64. }
  65.  
  66.  
  67.  
  68.  
  69.  
  70.  
  71.