Професионална програма
Loading...
+ Нов въпрос
eli.tt avatar eli.tt 1 Точки

Подготовка за изпит: зад. 2 "Билети за снукър" - помощ

Хайде, пак да си изпратя малко помощ и по 3-тата задача. Не успявам да си открия грешката в кода - Judge ми дава 80/100 - грешките са в 5-ия и 10-ия тест. Кодът е следният:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace World_Snooker_Championship
{
    class Program
    {
        static void Main(string[] args)
        {
            string stage = Console.ReadLine();
            string type = Console.ReadLine();
            int numTickets = int.Parse(Console.ReadLine());
            string picture = Console.ReadLine();
            double unitPrice = 0.0;
            double price = 0;

            if (stage == "Quarter final")
            {
                switch (type)
                {
                    case "Standard": unitPrice = 55.50; break;
                    case "Premium": unitPrice = 105.20; break;
                    case "VIP": unitPrice = 118.90; break;
                }
                switch (picture)
                {
                    case "Y": price = price + 40 * numTickets; break;
                    case "N": break;
                }
                price = numTickets * unitPrice;
            }
            else if (stage == "Semi final")
            {
                switch (type)
                {
                    case "Standard": unitPrice = 75.88; break;
                    case "Premium": unitPrice = 125.22; break;
                    case "VIP": unitPrice = 300.40; break;
                }
                switch (picture)
                {
                    case "Y": price = price + 40 * numTickets; break;
                    case "N": break;
                }
                price = numTickets * unitPrice;
            }
            else if (stage == "Final")
            {
                switch (type)
                {
                    case "Standard": unitPrice = 110.10; break;
                    case "Premium": unitPrice = 160.66; break;
                    case "VIP": unitPrice = 400; break;
                }
                switch (picture)
                {
                    case "Y": price = price + 40 * numTickets; break;
                    case "N": break;
                }
                price = numTickets * unitPrice;
            }

            if (price > 2500 && price <= 4000)
            {
                price = price * 0.90;
                switch (picture)
                {
                    case "Y": price = price + 40 * numTickets; break;
                    case "N": break;
                }
            }
            else if (price > 4000 && (picture == "Y" || picture == "N")) price = price * 0.75;
            
            Console.WriteLine($"{price:F2}");
        }
    }
}

Мерси на всички отзовали се с помощ.

0
Programming Basics with Java
vasil.vasileff avatar vasil.vasileff 3 Точки

Ето решението: https://pastebin.com/z365mAJa

Грешката ти, е някъде в изчисляването на отстъпките. Редактирал съм последните "if-else" конструкции.

 

0