Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int seats = Integer.parseInt(scanner.nextLine()),
- groupCount, income = 0;
- String command;
- while (!(command = scanner.nextLine()).equals("Movie time!")) {
- groupCount = Integer.parseInt(command);
- if (groupCount > seats) {
- break;
- }
- seats -= groupCount;
- income += groupCount * 5;
- if (groupCount % 3 == 0) {
- income -= 5;
- }
- }
- if (command.equals("Movie time!")) {
- System.out.printf("There are %d seats left in the cinema.\n", seats);
- } else {
- System.out.println("The cinema is full.");
- }
- System.out.printf("Cinema income - %d lv.\n", income);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement