Facebook
From Corrupt Bee, 3 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 51
  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.         } else if ("Varna".equals(town) || "Burgas".equals(town)) {
  22.             if (packet.equals("withBreakfast")) {
  23.                 price = 130;
  24.             } else if (packet.equals("noBreakfast")) {
  25.                 price = 100;
  26.             }
  27.         }
  28.         if (card.equals("yes")) {
  29.             if (packet.equals("withEquipment")) {
  30.                 price = 100 - 100 * 0.01;
  31.             } else if (packet.equals("noEquipment")) {
  32.                 price = 80 - 80 * 0.05;
  33.             } else if (packet.equals("withBreakfast")) {
  34.                 price = 130 - 130 * 0.12;
  35.             } else if (packet.equals("noBreakfast")) {
  36.                 price = 100 - 100 * 0.07;
  37.             }
  38.         }
  39.         if (countDays > 7) {
  40.             countDays = countDays - 1;
  41.         }
  42.         price = countDays * price;
  43.  
  44.         if ("Bansko".equals(town) || "Borovets".equals(town) || "Varna".equals(town) || "Burgas".equals(town)) {
  45.             if (packet.equals("withEquipment") || packet.equals("noEquipment") || packet.equals("withBreakfast") || packet.equals("noBreakfast")) {
  46.                 if (countDays > 1) {
  47.                     System.out.printf("The price is %.2flv! Have a nice time!", price);
  48.                 }
  49.             }
  50.         } else if (countDays < 1) {
  51.             System.out.println("Days must be positive number!");
  52.         } else {
  53.             System.out.println("Invalid input!");
  54.         }
  55.     }
  56. }
  57.  
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64.