SHARE
TWEET

Untitled

a guest Sep 21st, 2019 109 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Main {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner scanner = new Scanner(System.in);
  9.  
  10.         int groupOfPeople = Integer.parseInt(scanner.nextLine());
  11.         String typeOfGroup = scanner.nextLine();
  12.         String dayOfWeek = scanner.nextLine();
  13.  
  14.         double price = 0.0;
  15.         switch (typeOfGroup) {
  16.             case "Students":
  17.                 switch (dayOfWeek) {
  18.                     case "Friday": price = 8.45; break;
  19.                     case "Saturday": price = 9.80; break;
  20.                     case "Sunday": price = 10.46; break;
  21.                 }
  22.                 break;
  23.             case "Business":
  24.                 switch (dayOfWeek) {
  25.                     case "Friday": price = 10.90; break;
  26.                     case "Saturday": price = 15.60; break;
  27.                     case "Sunday": price = 16.00; break;
  28.                 }
  29.                 break;
  30.             case "Regular":
  31.                 switch (dayOfWeek) {
  32.                     case "Friday": price = 15.00; break;
  33.                     case "Saturday": price = 20.00; break;
  34.                     case "Sunday": price = 22.50; break;
  35.                 }
  36.                 break;
  37.         }
  38.  
  39.         double sum = groupOfPeople * price;
  40.  
  41.         if(typeOfGroup.equals("Students") && groupOfPeople >= 30) {
  42.             sum -= sum * 0.15;
  43.         }
  44.  
  45.         if(typeOfGroup.equals("Business") && groupOfPeople >= 100) {
  46.             sum = (groupOfPeople * 10) - sum;
  47.         }
  48.  
  49.         if(typeOfGroup.equals("Regular")) {
  50.             if(groupOfPeople >= 10 && groupOfPeople <= 20) {
  51.                 sum -= sum * 0.05;
  52.             }
  53.         }
  54.  
  55.         System.out.printf("Total price: %.2f", sum);
  56.     }
  57. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top