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