desislava_topuzakova

03. Vacation

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