Advertisement
Guest User

edited

a guest
Apr 2nd, 2020
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.21 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class test {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         String event = scan.nextLine();
  8.         String ticketType = scan.nextLine();
  9.         int ticketCount = Integer.parseInt(scan.nextLine());
  10.         String picture = scan.nextLine();
  11.  
  12.         double ticketPrice = 0.0;
  13.         double totalPrice;
  14.  
  15.         switch (ticketType){
  16.             case "Standard":
  17.                 switch (event) {
  18.                     case "Quarter final":
  19.                         ticketPrice = 55.50;
  20.                         break;
  21.                     case "Semi final":
  22.                         ticketPrice = 75.88;
  23.                         break;
  24.                     case "Final":
  25.                         ticketPrice = 110.10;
  26.                         break;
  27.                 }
  28.                 break;
  29.             case "Premium":
  30.                 switch (event) {
  31.                     case "Quarter final":
  32.                         ticketPrice = 105.20;
  33.                         break;
  34.                     case "Semi final":
  35.                         ticketPrice = 125.22;
  36.                         break;
  37.                     case "Final":
  38.                         ticketPrice = 160.66;
  39.                         break;
  40.                 }
  41.                 break;
  42.             case "VIP":
  43.                 switch (event) {
  44.                     case "Quarter final":
  45.                         ticketPrice = 118.90;
  46.                         break;
  47.                     case "Semi final":
  48.                         ticketPrice = 300.40;
  49.                         break;
  50.                     case "Final":
  51.                         ticketPrice = 400.00;
  52.                         break;
  53.                 }
  54.                 break;
  55.         }
  56.         totalPrice = ticketPrice * ticketCount;
  57.         boolean freePicture = false;
  58.  
  59.         if (totalPrice > 4000) {
  60.             totalPrice *= 0.75;
  61.             freePicture = true;
  62.         }
  63.         else if (totalPrice > 2500){
  64.             totalPrice *= 0.9;
  65.         }
  66.         if (picture.equals("Y") && !freePicture){
  67.             totalPrice += 40 * ticketCount;
  68.         }
  69.         System.out.printf("%.2f", totalPrice);
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement