Advertisement
mark79

Java Fundamentals - Vacation

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