Advertisement
Guest User

Untitled

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