Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Test {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int standardCount = 0;
- int studentCount = 0;
- int kidCount = 0;
- int people = 0;
- String filmName = scanner.nextLine();
- while (!"Finish".equals(filmName)){
- int freeSpaces = Integer.parseInt(scanner.nextLine());
- int peopleInRoom = 0;
- for (int i = 0; i < freeSpaces; i++){
- String type = scanner.nextLine();
- if ( "End".equals(type)){
- break;
- }
- peopleInRoom++;
- people++;
- switch (type){
- case "standard":
- standardCount++;
- break;
- case "student":
- studentCount++;
- break;
- case "kid":
- kidCount++;
- break;
- }
- }
- double perc = (peopleInRoom*1.0/freeSpaces) * 100;
- System.out.printf("%s - %.2f%% full.", filmName, perc).println();
- filmName = scanner.nextLine();
- }
- double standardPerc = (standardCount*1.0/people) * 100;
- double studentPerc = (studentCount*1.0/people) * 100;
- double kidPerc = (kidCount*1.0/people) * 100;
- System.out.printf("Total tickets: %d",people).println();
- System.out.printf("%.2f%% student tickets.", studentPerc).println();
- System.out.printf("%.2f%% standard tickets.", standardPerc).println();
- System.out.printf("%.2f%% kids tickets.", kidPerc);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement