Advertisement
Spocoman

Oscars week in cinema

Sep 8th, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.22 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.         String movieName = scanner.nextLine(),
  7.                 typeOfHall = scanner.nextLine();
  8.         int ticketCount = Integer.parseInt(scanner.nextLine());
  9.         double ticketPrice = 0;
  10.  
  11.         if (movieName.equals("A Star Is Born")) {
  12.             if (typeOfHall.equals("normal")) {
  13.                 ticketPrice = 7.50;
  14.             } else if (typeOfHall.equals("luxury")) {
  15.                 ticketPrice = 10.50;
  16.             } else if (typeOfHall.equals("ultra luxury")) {
  17.                 ticketPrice = 13.50;
  18.             }
  19.         } else if (movieName.equals("Bohemian Rhapsody")) {
  20.             if (typeOfHall.equals("normal")) {
  21.                 ticketPrice = 7.35;
  22.             } else if (typeOfHall.equals("luxury")) {
  23.                 ticketPrice = 9.45;
  24.             } else if (typeOfHall.equals("ultra luxury")) {
  25.                 ticketPrice = 12.75;
  26.             }
  27.         } else if (movieName.equals("Green Book")) {
  28.             if (typeOfHall.equals("normal")) {
  29.                 ticketPrice = 8.15;
  30.             } else if (typeOfHall.equals("luxury")) {
  31.                 ticketPrice = 10.25;
  32.             } else if (typeOfHall.equals("ultra luxury")) {
  33.                 ticketPrice = 13.25;
  34.             }
  35.         } else if (movieName.equals("The Favourite")) {
  36.             if (typeOfHall.equals("normal")) {
  37.                 ticketPrice = 8.75;
  38.             } else if (typeOfHall.equals("luxury")) {
  39.                 ticketPrice = 11.55;
  40.             } else if (typeOfHall.equals("ultra luxury")) {
  41.                 ticketPrice = 13.95;
  42.             }
  43.         }
  44.  
  45.         System.out.printf("%s -> %.2f lv.\n", movieName, ticketPrice * ticketCount);
  46.     }
  47. }
  48.  
  49. ИЛИ:
  50.  
  51. import java.util.Scanner;
  52.  
  53. public class Main {
  54.     public static void main(String[] args) {
  55.         Scanner scanner = new Scanner(System.in);
  56.         String movieName = scanner.nextLine(),
  57.                 typeOfHall = scanner.nextLine();
  58.         int ticketCount = Integer.parseInt(scanner.nextLine());
  59.        
  60.         double ticketPrice = switch (movieName) {
  61.             case "A Star Is Born" -> switch (typeOfHall) {
  62.                 case "normal" -> 7.50;
  63.                 case "luxury" -> 10.50;
  64.                 case "ultra luxury" -> 13.50;
  65.                 default -> 0;
  66.             };
  67.             case "Bohemian Rhapsody" -> switch (typeOfHall) {
  68.                 case "normal" -> 7.35;
  69.                 case "luxury" -> 9.45;
  70.                 case "ultra luxury" -> 12.75;
  71.                 default -> 0;
  72.             };
  73.             case "Green Book" -> switch (typeOfHall) {
  74.                 case "normal" -> 8.15;
  75.                 case "luxury" -> 10.25;
  76.                 case "ultra luxury" -> 13.25;
  77.                 default -> 0;
  78.             };
  79.             case "The Favourite" -> switch (typeOfHall) {
  80.                 case "normal" -> 8.75;
  81.                 case "luxury" -> 11.55;
  82.                 case "ultra luxury" -> 13.95;
  83.                 default -> 0;
  84.             };
  85.             default -> 0;
  86.         };
  87.  
  88.         System.out.printf("%s -> %.2f lv.\n", movieName, ticketPrice * ticketCount);
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement