Advertisement
Ivelin_Arsov

Vacation

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