Loading...

Във форума е въведено ограничение, което позволява на потребителите единствено да разглеждат публикуваните въпроси.

Tihomirtx88 avatar Tihomirtx88 9 Точки

Къде ми е проблемът с тази задача 66/100 ?Fishing Boat

using System;

namespace FishingBoat
{
    class Program
    {
        static void Main(string[] args)
        {
            
            const int sprintPrice = 3000;
            const int summerAndAutumnPrice = 4200;
            const int winterPrice = 2600;
            int budjet = int.Parse(Console.ReadLine());
            string season = Console.ReadLine();
            int numberOfFishing = int.Parse(Console.ReadLine());
            
            double totalPrice = 0;


            switch (season)
            {
                case "Srping":
                    totalPrice = sprintPrice;
                    break;
                case "Summer":
                    totalPrice = summerAndAutumnPrice;
                    break;
                case "Autumn":
                    totalPrice = summerAndAutumnPrice;
                    break;
                case "Winter":
                    totalPrice = winterPrice;
                    break;
            }
            if (numberOfFishing <= 6)
            {
                totalPrice -= totalPrice * 0.10;
            }
            else if (numberOfFishing >= 7 && numberOfFishing <= 11)
            {
                totalPrice -= totalPrice * 0.15;
            }
            else
            {
                totalPrice -= totalPrice * 0.25;
            }
            if (numberOfFishing % 2 == 0 && season != "Autumn")
            {
                totalPrice -= totalPrice * 0.05;
            }
            if (budjet >= totalPrice)
            {
                double moneyLeft = budjet - totalPrice;
                Console.WriteLine($"Yes! You have {moneyLeft:f2} leva left.");
            }
            else if (budjet < totalPrice)
            {
                double moneyNeed = totalPrice - budjet;
                Console.WriteLine($"Not enough money! You need {moneyNeed:f2} leva.");
            }
        }
    }
}
 

Тагове:
0
Programming Basics with C#
kkaraivanov avatar kkaraivanov 486 Точки

Здравей. На пръв поглед изглежда Ок.....Пращам ти кода с корекция. Тествай, надявам се да върне 100/100

static void Main(string[] args)
        {
            int groupBudget = int.Parse(Console.ReadLine());
            string sezonName = Console.ReadLine();
            int fisherManCount = int.Parse(Console.ReadLine());
            double rent = 0;

            switch (sezonName)
            {
                case "Spring":
                    rent = GetPrice("Spring", fisherManCount, 3000);
                    break;
                case "Summer":
                    rent = GetPrice("Summer", fisherManCount, 4200);
                    break;
                case "Autumn":
                    rent = GetPrice("Autumn", fisherManCount, 4200);
                    break;
                case "Winter":
                    rent = GetPrice("Winter", fisherManCount, 2600);
                    break;
            }

            double totalPrice = Math.Abs(groupBudget - rent);

            if (rent <= groupBudget)
            {
                Console.WriteLine($"Yes! You have {totalPrice:f2} leva left.");
            }
            else
            {
                Console.WriteLine($"Not enough money! You need {totalPrice:f2} leva.");
            }
        }

        private static double GetPrice(string sezonName, int fisherManCount, double price)
        {
            double discount = 0;
            string sezon = "Autumn";

            if (fisherManCount >= 12)
            {
                discount = price * 0.25;
                price -= discount;
            }
            else if (fisherManCount >= 7 && fisherManCount <= 11)
            {
                discount = price * 0.15;
                price -= discount;
            }
            else
            {
                discount = price * 0.10;
                price -= discount;
            }

            if (fisherManCount % 2 == 0 && sezonName != sezon)
            {
                discount = price * 0.05;
                price -= discount;
            }

            return price;
        }

 

0
22/02/2021 13:57:49
protliife avatar protliife -2 Точки

es off them. and on they went, till the activity was pretty done, and the footwear stood equipped to be used upon the desk. this become long before dawn; and then they bustled away as short as lightning.
business voip service

 

-2
Tihomirtx88 avatar Tihomirtx88 9 Точки

Благодаря ти колега,помогна кода,а иначе доста често ми се закучват ей така задчите на наглед вярно решение ..

0
Можем ли да използваме бисквитки?
Ние използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Можете да се съгласите с всички или част от тях.
Назад
Функционални
Използваме бисквитки и подобни технологии, за да предоставим нашите услуги. Използваме „сесийни“ бисквитки, за да Ви идентифицираме временно. Те се пазят само по време на активната употреба на услугите ни. След излизане от приложението, затваряне на браузъра или мобилното устройство, данните се трият. Използваме бисквитки, за да предоставим опцията „Запомни Ме“, която Ви позволява да използвате нашите услуги без да предоставяте потребителско име и парола. Допълнително е възможно да използваме бисквитки за да съхраняваме различни малки настройки, като избор на езика, позиции на менюта и персонализирано съдържание. Използваме бисквитки и за измерване на маркетинговите ни усилия.
Рекламни
Използваме бисквитки, за да измерваме маркетинг ефективността ни, броене на посещения, както и за проследяването дали дадено електронно писмо е било отворено.