Advertisement
Spocoman

Cinema

Sep 3rd, 2024
40
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.92 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.         int seats = Integer.parseInt(scanner.nextLine()),
  7.                 groupCount, income = 0;
  8.  
  9.         String command;
  10.         while (!(command = scanner.nextLine()).equals("Movie time!")) {
  11.             groupCount = Integer.parseInt(command);
  12.             if (groupCount > seats) {
  13.                 break;
  14.             }
  15.  
  16.             seats -= groupCount;
  17.             income += groupCount * 5;
  18.  
  19.             if (groupCount % 3 == 0) {
  20.                 income -= 5;
  21.             }
  22.         }
  23.  
  24.         if (command.equals("Movie time!")) {
  25.             System.out.printf("There are %d seats left in the cinema.\n", seats);
  26.         } else {
  27.             System.out.println("The cinema is full.");
  28.         }
  29.         System.out.printf("Cinema income - %d lv.\n", income);
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement