Guest User

Vacation

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