Advertisement
Guest User

Untitled

a guest
May 19th, 2019
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.07 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 people = Integer.parseInt(scanner.nextLine());
  8.         String grope = scanner.nextLine();
  9.         String day = scanner.nextLine();
  10.  
  11.         double price = 0;
  12.  
  13.  
  14.         switch (day) {
  15.             case "Friday":
  16.                 if (grope.equals("Students")) {
  17.                     price = 8.45;
  18.                 } else if (grope.equals("Business")) {
  19.                     price = 10.90;
  20.                 } else if (grope.equals("Regular")) {
  21.                     price = 15;
  22.                 }
  23.                 break;
  24.             case "Saturday":
  25.                 if (grope.equals("Students")) {
  26.                     price = 9.80;
  27.                 } else if (grope.equals("Business")) {
  28.                     price = 15.60;
  29.                 } else if (grope.equals("Regular")) {
  30.                     price = 20;
  31.                 }
  32.                 break;
  33.             case "Sunday":
  34.                 if (grope.equals("Students")) {
  35.                     price = 10.46;
  36.                 } else if (grope.equals("Business")) {
  37.                     price = 16;
  38.                 } else if (grope.equals("Regular")) {
  39.                     price = 22.50;
  40.                 }
  41.                 break;
  42.         }
  43.  
  44.         double totalPrice = people * price;
  45.  
  46.         if (grope.equals("Students") && people >= 30) {
  47.             totalPrice = totalPrice - (totalPrice * 0.15);
  48.             System.out.printf("Total price: %.2f", totalPrice);
  49.         } else if (grope.equals("Business") && people >= 100) {
  50.             people -= 10;
  51.             double discount = people * price;
  52.             System.out.printf("Total price: %.2f", discount);
  53.         } else if (grope.equals("Regular") && people >= 10 && people <= 20) {
  54.             totalPrice = totalPrice - (totalPrice * 0.05);
  55.             System.out.printf("Total price: %.2f", totalPrice);
  56.         }else {
  57.             System.out.printf("Total price: %.2f", totalPrice);
  58.         }
  59.  
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement