Didart

Vacation

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