Lyubohd

03. Cruise Ship

Feb 22nd, 2020
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Problem03 {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         String sea = scan.nextLine();
  8.         String cabin = scan.nextLine();
  9.         int nightsCount = Integer.parseInt(scan.nextLine());
  10.  
  11.         double price = 0.0;
  12.         switch (cabin) {
  13.             case "standard cabin":
  14.                 if ("Mediterranean".equals(sea)) {
  15.                     price = 27.50;
  16.                 } else if ("Adriatic".equals(sea)) {
  17.                     price = 22.99;
  18.                 } else if ("Aegean".equals(sea)) {
  19.                     price = 23.00;
  20.                 }
  21.                 break;
  22.             case "cabin with balcony":
  23.                 if ("Mediterranean".equals(sea)) {
  24.                     price = 30.20;
  25.                 } else if ("Adriatic".equals(sea)) {
  26.                     price = 25.00;
  27.                 } else if ("Aegean".equals(sea)) {
  28.                     price = 26.60;
  29.                 }
  30.                 break;
  31.             case "apartment":
  32.                 if ("Mediterranean".equals(sea)) {
  33.                     price = 40.50;
  34.                 } else if ("Adriatic".equals(sea)) {
  35.                     price = 34.99;
  36.                 } else if ("Aegean".equals(sea)) {
  37.                     price = 39.80;
  38.                 }
  39.                 break;
  40.         }
  41.  
  42.         price = price * 4 * nightsCount;
  43.         if (nightsCount > 7) {
  44.             price = price * 0.75; // price - price * 0.25
  45.         }
  46.  
  47.         System.out.printf("Annie's holiday in the %s sea costs %.2f lv.", sea, price);
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment