Advertisement
Guest User

Untitled

a guest
Jun 20th, 2019
782
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.04 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Cinema_2 {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int capacity = Integer.parseInt(scanner.nextLine());
  8.         String input = scanner.nextLine();
  9.         int totalSum = 0;
  10.  
  11.         while (!input.equals("Movie time!")) {
  12.  
  13.             int countPeople = Integer.parseInt(input);
  14.             capacity -= countPeople;
  15.  
  16.             if (countPeople % 3 == 0) {
  17.                 totalSum += (countPeople * 5) - 5;
  18.             } else {
  19.                 totalSum += countPeople * 5;
  20.             }
  21.  
  22.             if (countPeople > capacity) {
  23.                
  24.                 break;
  25.             }
  26.  
  27.             input = scanner.nextLine();
  28.         }
  29.         if (capacity > 0 || capacity == 0) {
  30.             System.out.printf("There are %d seats left in the cinema.%n", capacity);
  31.  
  32.         }else {
  33.             System.out.printf("The cinema is full.%n");
  34.         }
  35.  
  36.         System.out.printf("Cinema income - %d lv.", totalSum);
  37.  
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement