Advertisement
Dido09

CinemaTickets

Oct 23rd, 2019
208
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class Solving {
  4. public static void main(String[] args) {
  5. Scanner read = new Scanner(System.in);
  6. String filmName = "";
  7.  
  8. double student = 0;
  9. double standart = 0;
  10. double kid = 0;
  11. double totalTickets = 0;
  12.  
  13.  
  14. while (!"Finish".equals(filmName=read.nextLine())){
  15.  
  16. int freeSpaces = Integer.parseInt(read.nextLine());
  17.  
  18. double human = 0;
  19. for (int i = 0; i < freeSpaces; i++) {
  20.  
  21. String type = read.nextLine();
  22.  
  23. switch (type){
  24. case "student":
  25. student++;
  26. break;
  27. case "standard":
  28. standart++;
  29. break;
  30. case "kid":
  31. kid++;
  32. break;
  33. }
  34. if (type.equals("End")||human>=freeSpaces){
  35. break;
  36. }
  37. human++;
  38. totalTickets++;
  39. }
  40. System.out.printf("%s - %.2f%% full.\n",filmName,(human/freeSpaces)*100.00);
  41. }
  42. System.out.printf("Total tickets: %.0f\n",totalTickets);
  43. System.out.printf("%.2f%% student tickets.\n",(student/totalTickets)*100);
  44. System.out.printf("%.2f%% standard tickets.\n",(standart/totalTickets)*100);
  45. System.out.printf("%.2f%% kids tickets.\n",(kid/totalTickets)*100);
  46. }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement