Advertisement
AngelKejov

Vacantion

May 21st, 2021
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.72 KB | None | 0 0
  1. package Exersises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Vacation {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.  
  10.         int people = Integer.parseInt(sc.nextLine());
  11.         String groupType = sc.nextLine();
  12.         String day = sc.nextLine();
  13.  
  14.         double price = 0;
  15.         double total = 0;
  16.  
  17.         switch (groupType) {
  18.             case "Students" -> {
  19.                 switch (day) {
  20.                     case "Friday" -> price = 8.45;
  21.                     case "Saturday" -> price = 9.80;
  22.                     case "Sunday" -> price = 10.46;
  23.                 }
  24.                 total = price * people;
  25.                 if (people >= 30) {
  26.                     total = total - (total * 0.15);
  27.                 }
  28.             }
  29.             case "Business" -> {
  30.                 price = switch (day) {
  31.                     case "Friday" -> 10.90;
  32.                     case "Saturday" -> 15.60;
  33.                     case "Sunday" -> 16;
  34.                     default -> price;
  35.                 };
  36.                 total = price * people;
  37.                 if (people >= 100) {
  38.                     total = total - (10 * price);
  39.                 }
  40.             }
  41.             case "Regular" -> {
  42.                 price = switch (day) {
  43.                     case "Friday" -> 15;
  44.                     case "Saturday" -> 20;
  45.                     case "Sunday" -> 22.50;
  46.                     default -> price;
  47.                 };
  48.                 total = price * people;
  49.                 if (people >= 10 && people <= 20) {
  50.                     total = total - (total * 0.15);
  51.                 }
  52.             }
  53.         }
  54.  
  55.         System.out.printf("Total price: %.2f", total);
  56.     }
  57. }
  58.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement