Guest User

Задача04 -Кино

a guest
Nov 27th, 2019
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Cinema {
  3. public static void main(String[] args) {
  4. Scanner scanner = new Scanner(System.in);
  5. int capacity = Integer.parseInt(scanner.nextLine());
  6. String input = scanner.nextLine();
  7.  
  8. int totalPeople = 0;
  9. int currentPeople =0;
  10. double discount = 0;
  11.  
  12. while ( totalPeople <=capacity) {
  13. if (!"Movie time!".equals(input)) {
  14. currentPeople = Integer.parseInt(input);
  15. totalPeople +=currentPeople;
  16. if (currentPeople%3==0){
  17. discount+=5;
  18. }
  19. if (totalPeople>capacity) {
  20. System.out.println("The cinema is full.");
  21. break;
  22. }
  23. input=scanner.nextLine();
  24. }else if ("Movie time!".equals(input)){
  25. System.out.printf("There are %d seats left in the cinema.%n", capacity-totalPeople);
  26. break;
  27. }
  28. }
  29.  
  30. if (totalPeople>capacity){
  31. totalPeople-=currentPeople;
  32. }
  33. double allMoney=totalPeople*5-discount;
  34.  
  35.  
  36. System.out.printf("Cinema income - %.0f lv.", allMoney);
  37.  
  38.  
  39. }
  40. }
Add Comment
Please, Sign In to add comment