Advertisement
GabrielHr00

01. Cinema

Mar 24th, 2024
596
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. package _03_ConditionalStatementsAdvanced;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Cinema {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String ticketType = scanner.nextLine();
  9.         int rows = Integer.parseInt(scanner.nextLine());
  10.         int columns = Integer.parseInt(scanner.nextLine());
  11.  
  12.         int seatsAll = rows * columns;
  13.         double totalPrice = 0.0;
  14.  
  15. //        if (ticketType.equals("Premiere")) {
  16. //            totalPrice = 12.0 * seatsAll;
  17. //        } else if (ticketType.equals("Normal")) {
  18. //            totalPrice = 7.50 * seatsAll;
  19. //        } else if (ticketType.equals("Discount")) {
  20. //            totalPrice = 5.0 * seatsAll;
  21. //        }
  22.  
  23.         switch (ticketType) {
  24.             case "Premiere":
  25.                 totalPrice = 12.0 * seatsAll;
  26.                 break;
  27.             case "Normal":
  28.                 totalPrice = 7.50 * seatsAll;
  29.                 break;
  30.             case "Discount":
  31.                 totalPrice = 5.0 * seatsAll;
  32.                 break;
  33.         }
  34.  
  35.         System.out.printf("%.2f leva", totalPrice);
  36.  
  37.     }
  38. }
  39.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement