desislava_topuzakova

01. Кино

Nov 14th, 2021
837
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. package ConditionalStatementsAdvanced;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Cinema_01 {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner(System.in);
  8.         String type = scanner.nextLine();
  9.         int rows = Integer.parseInt(scanner.nextLine());
  10.         int cols = Integer.parseInt(scanner.nextLine());
  11.  
  12.         //обща сума = бр. билетите (редове * колони) * цена на 1 билет (зависи от типа на прожекцията)
  13.         int countTickets = rows * cols; //бр. билетите = бр. местата в залата
  14.         double pricePerTicket = 0; //цена за 1 билет
  15.  
  16.         if (type.equals("Premiere")) {
  17.             pricePerTicket = 12;
  18.         } else if (type.equals("Normal")) {
  19.             pricePerTicket = 7.50;
  20.         } else if (type.equals("Discount")) {
  21.             pricePerTicket = 5;
  22.         }
  23.  
  24.         double totalSum = countTickets * pricePerTicket;
  25.         System.out.printf("%.2f leva", totalSum);
  26.     }
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment