Advertisement
Guest User

Vacation

a guest
Jan 22nd, 2020
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.42 KB | None | 0 0
  1. import java.math.BigDecimal;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.Scanner;
  5.  
  6. public class Vacation{
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         Scanner scan = new Scanner(System.in);
  11.         int number = Integer.parseInt(scan.nextLine());
  12.         String peopleType = scan.nextLine();
  13.         String weekDay = scan.nextLine();
  14.         double pricePerson = 0.0;
  15.         double totalPrice = 0.0;
  16.  
  17.         switch (peopleType) {
  18.             case "Students": {
  19.                 switch (weekDay) {
  20.                     case "Friday":
  21.                         pricePerson = 8.45;
  22.                         break;
  23.                     case "Saturday":
  24.                         pricePerson = 9.80;
  25.                         break;
  26.                     case "Sunday":
  27.                         pricePerson = 10.46;
  28.                         break;
  29.                 }
  30.  
  31.  
  32.  
  33.                 break;
  34.             }
  35.             case "Business": {
  36.                 switch (weekDay) {
  37.                     case "Friday":
  38.                         pricePerson = 10.90;
  39.                         break;
  40.                     case "Saturday":
  41.                         pricePerson = 15.60;
  42.                         break;
  43.                     case "Sunday":
  44.                         pricePerson = 16.00;
  45.                         break;
  46.                 }
  47.  
  48.  
  49.                 break;
  50.             }
  51.             case "Regular": {
  52.                 switch (weekDay) {
  53.                     case "Friday":
  54.                         pricePerson = 15;
  55.                         break;
  56.                     case "Saturday":
  57.                         pricePerson = 20;
  58.                         break;
  59.                     case "Sunday":
  60.                         pricePerson = 22.50;
  61.                         break;
  62.                 }
  63.  
  64.  
  65.  
  66.                 break;
  67.             }
  68.         }
  69.         totalPrice = number * pricePerson;
  70.         if (number >= 30 && peopleType.equals("Students")) {
  71.             totalPrice = 0.85 * totalPrice;
  72.  
  73.         }
  74.         if (number >= 100 && peopleType.equals("Business")) {
  75.             totalPrice = (number * pricePerson) - 10 * pricePerson;
  76.  
  77.         }
  78.         if (number >= 10 && number <= 20 && peopleType.equals("Regular")) {
  79.             totalPrice = 0.95 * totalPrice;
  80.  
  81.  
  82.         }
  83.         System.out.printf("Total price: %.2f", totalPrice);
  84.     }
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement