Advertisement
Valantina

Cinema

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