Софтуерно Инженерство
Loading...
+ Нов въпрос
TeodorPavlov avatar TeodorPavlov 5 Точки

Задача 6. Билети за кино

Здравейте, реших тази задача:

https://softuni.bg/downloads/svn/programming-basics-v4/course-directories/may-2019/2019-02/Exam/06.%20Cinema%20Tickets.pdf

по-този начин:

https://pastebin.com/EYtjb3zD

В IDE-то всичко работи както трябва, но като я пусна в judge ми дава нула точки.

Някой може ли да ми каже къде е грешката?

Благодаря

Тагове:
0
Основи на програмирането 01/09/2019 14:04:44
RuNNeR4142 avatar RuNNeR4142 391 Точки

Решение на Java, дано е полезно:

 

public class E06CinemaTickets {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        int studentTotal = 0;
        int standardTotal = 0;
        int kidTotal = 0;
        int ticketsTotal = 0;

        while (!input.equals("Finish")) {
            String movieName = input;
            int seats = Integer.parseInt(scanner.nextLine());
            int student = 0;
            int standard = 0;
            int kid = 0;

            for (int i = 1; i <= seats ; i++) {
                input = scanner.nextLine();
                if (input.equals("End")) {
                    break;
                }
                if (input.equals("student")) {
                    student++;
                } else if (input.equals("standard")) {
                    standard++;
                } else {
                    kid++;
                }
            }
            double tickets = student + standard + kid;
            studentTotal += student;
            standardTotal += standard;
            kidTotal += kid;
            ticketsTotal += tickets;

            System.out.printf("%s - %.2f%% full.%n", movieName, tickets * 100 / seats);
            input = scanner.nextLine();
        }
        System.out.printf("Total tickets: %d%n", ticketsTotal);
        System.out.printf("%.2f%% student tickets.%n", studentTotal * 100 / (double) ticketsTotal);
        System.out.printf("%.2f%% standard tickets.%n", standardTotal * 100 / (double) ticketsTotal);
        System.out.printf("%.2f%% kids tickets.", kidTotal * 100 / (double) ticketsTotal);
    }
}
0
TeodorPavlov avatar TeodorPavlov 5 Точки

Благодаря!

0