Advertisement
CR7CR7

vasko

Feb 22nd, 2023
880
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 ProblemCinema {
  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.  
  10.         double income = 0;
  11.  
  12.         while (!input.equals("Movie time!")) {
  13.             int people = Integer.parseInt(input);
  14.  
  15.             if (people <= capacity) {
  16.                 capacity -= people;
  17.                 income += people * 5;
  18.                 if (people % 3 == 0) {
  19.                     income -= 5;
  20.                 }
  21.             } else {
  22.                 System.out.println("The cinema is full.");
  23.                 System.out.printf("Cinema income - %.0f lv.", income);
  24.                 break;
  25.             }
  26.             input = scanner.nextLine();
  27.         }
  28.  
  29.         if (input.equals("Movie time!")) {
  30.             System.out.printf("There are %d seats left in the cinema.%n", capacity);
  31.             System.out.printf("Cinema income - %.0f lv.", income);
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement