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