Advertisement
Guest User

03. World Snooker Championship

a guest
Oct 23rd, 2019
835
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String typeOfChampionship = scanner.nextLine().toLowerCase();
  8.         String typeOfTicket = scanner.nextLine().toLowerCase();
  9.         int countOfTickets = Integer.parseInt(scanner.nextLine());
  10.         String pictureWithTrophy = scanner.nextLine().toLowerCase();
  11.         double totalPrice = 0;
  12.         double picturePrice = 0;
  13.  
  14.         switch (typeOfChampionship){
  15.             case "final":
  16.                 if (typeOfTicket.equals("premium")){
  17.                     totalPrice = countOfTickets * 160.66;
  18.                 }
  19.                 else if (typeOfTicket.equals("standard")) {
  20.                     totalPrice = countOfTickets * 110.10;
  21.                 }
  22.                 else if (typeOfTicket.equals("vip")) {
  23.                     totalPrice = countOfTickets * 400;
  24.                 }
  25.                 break;
  26.             case "semi final":
  27.                 if (typeOfTicket.equals("premium")){
  28.                     totalPrice = countOfTickets * 125.22;
  29.                 }
  30.                 else if (typeOfTicket.equals("standard")) {
  31.                     totalPrice = countOfTickets * 75.88;
  32.                 }
  33.                 else if (typeOfTicket.equals("vip")) {
  34.                     totalPrice = countOfTickets * 300.40;
  35.                 }
  36.                 break;
  37.             case "quarter final":
  38.                 if (typeOfTicket.equals("premium")){
  39.                     totalPrice = countOfTickets * 105.20;
  40.                 }
  41.                 else if (typeOfTicket.equals("standard")) {
  42.                     totalPrice = countOfTickets * 55.50;
  43.                 }
  44.                 else if (typeOfTicket.equals("vip")) {
  45.                     totalPrice = countOfTickets * 118.90;
  46.                 }
  47.                 break;
  48.             default:{
  49.                 break;
  50.             }
  51.         }
  52.  
  53.         if (totalPrice > 4000){
  54.             totalPrice = 0.75 * totalPrice;
  55.             System.out.printf("%.2f", totalPrice);
  56.         }
  57.         else if (totalPrice > 2500){
  58.             totalPrice *= 0.9;
  59.             if (pictureWithTrophy.equals("y")){
  60.                 picturePrice = countOfTickets * 40;
  61.                 totalPrice += picturePrice;
  62.                 System.out.printf("%.2f", totalPrice);
  63.             }
  64.             else {
  65.                 System.out.printf("%.2f", totalPrice);
  66.             }
  67.         }
  68.         else {
  69.             if (pictureWithTrophy.equals("y")){
  70.                 picturePrice = countOfTickets * 40;
  71.                 totalPrice += picturePrice;
  72.                 System.out.printf("%.2f", totalPrice);
  73.             }
  74.             else {
  75.                 System.out.printf("%.2f", totalPrice);
  76.             }
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement