Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- import java.util.function.DoubleUnaryOperator;
- public class CinemaTickets {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- String nameMovie = scanner.nextLine();
- Integer total_student = 0;
- Integer total_kid = 0;
- Integer total_standard = 0;
- Integer total_ticket = 0;
- while(!"Finish".equals(nameMovie)){
- Integer counter_student = 0;
- Integer counter_standard = 0;
- Integer counter_kid = 0;
- Integer total_counter = 0;
- Integer free_places = Integer.parseInt(scanner.nextLine());
- String type = scanner.nextLine();
- while (!"End".equals(type)){
- if("student".equals(type)){
- counter_student += 1;
- }else if("standard".equals(type)){
- counter_standard += 1;
- }else if("kid".equals(type)){
- counter_kid += 1;
- }
- total_counter +=1;
- if(total_counter >= free_places){
- break;
- }else{
- type = scanner.nextLine();
- }
- }
- Double totalCounter = total_counter.doubleValue();
- Double freePlaces = free_places.doubleValue();
- Double capacity = ((totalCounter / freePlaces) * 100);
- System.out.printf("%s - %.2f", nameMovie, capacity);
- System.out.println("% full.");
- total_kid += counter_kid;
- total_standard += counter_standard;
- total_student += counter_student;
- total_ticket = total_standard + total_student + total_kid;
- nameMovie = scanner.nextLine();
- }
- Double totalStudens = total_student.doubleValue();
- Double totalStandard = total_standard.doubleValue();
- Double totalKid = total_kid.doubleValue();
- Double precentStudet = (totalStudens / total_ticket)*100;
- Double precentStandard = (totalStandard / total_ticket)*100;
- Double precentKid = (totalKid / total_ticket)*100;
- System.out.printf("Total tickets: %d\n",total_ticket);
- System.out.printf("%.2f", precentStudet);
- System.out.print("% student tickets.\n");
- System.out.printf("%.2f", precentStandard);
- System.out.print("% standard tickets.\n");
- System.out.printf("%.2f", precentKid);
- System.out.print("% kids tickets.\n");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment