Advertisement
Spocoman

01. Cinema

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