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

Gaming Store C#

Здравейте! 
Джъджа ми дава само 20/100, а локално програмата ми работи с тестовете. Не успявам да си намеря грешката и бих се радвал, ако някой помогне :)
Става дума за задача 3 - https://softuni.bg/trainings/resources/officedocument/37240/more-exercise-technology-fundamentals-with-csharp-january-2019/2237 / Gaming Store.
Кода:
https://pastebin.com/qAE5whLL
 

Тагове:
0
Fundamentals Module
Ivan_Lefterov avatar Ivan_Lefterov 12 Точки
Best Answer

Здравей, написал си CS: GO, а по условие е CS: OG :). Малка грешка, но ти пропуска цяла проверка.

0
NLulchev avatar NLulchev 5 Точки

хаха да, много ти благодаря! :)

0
nikolaykaradzhov avatar nikolaykaradzhov 1 Точки

Здравей,

 

Ето ти едно работещо решение. Погледни кода и анализирай. 

https://pastebin.com/kvTK2xax

Успех

0
NLulchev avatar NLulchev 5 Точки

Благодаря ти!

0
koknq avatar koknq 17 Точки

using System;

namespace ConsoleApp8
{
    class Program
    {
        static void Main(string[] args)
        {
            double balance = double.Parse(Console.ReadLine());
            double priceOF = 39.99;
            double priceCS = 15.99;
            double priceZZ = 19.99;
            double priceH = 59.99;
            double priceRW = 29.99;
            double priceRWO = 39.99;
            double totalspent = 0;
            double remaining = 0;
            while (true)
            {
                string game = Console.ReadLine();
                if(game == "OutFall 4")
                {
                    if(balance>priceOF)
                    {
                        Console.WriteLine($"Bought {game}");
                        balance -= priceOF;
                        totalspent += priceOF;
                        
                    }
                    else if(balance==priceOF)
                    {
                        Console.WriteLine($"Bought {game}");
                        Console.WriteLine("Out of money!"); break;
                    }
                    else
                    {
                        Console.WriteLine("Too Expensive"); continue;
                    }
                }
                else if (game == "CS: OG")
                {
                    if (balance > priceCS)
                    {
                        Console.WriteLine($"Bought {game}");
                        balance -= priceCS;
                        totalspent += priceCS;
                        
                    }
                    else if (balance == priceCS)
                    {
                        Console.WriteLine($"Bought {game}");
                        Console.WriteLine("Out of money!"); break;
                    }
                    else
                    {
                        Console.WriteLine("Too Expensive"); continue;
                    }
                }
                else if (game == "Zplinter Zell")
                {
                    if (balance > priceZZ)
                    {
                        Console.WriteLine($"Bought {game}");
                        balance -= priceZZ;
                        totalspent += priceZZ;
                        
                    }
                    else if (balance == priceZZ)
                    {
                        Console.WriteLine($"Bought {game}");
                        Console.WriteLine("Out of money!"); break;
                    }
                    else
                    {
                        Console.WriteLine("Too Expensive"); continue;
                    }
                }
                else if (game == "Honored 2")
                {
                    if (balance > priceH)
                    {
                        Console.WriteLine($"Bought {game}");
                        balance -= priceH;
                        totalspent += priceH;
                        
                    }
                    else if (balance == priceH)
                    {
                        Console.WriteLine($"Bought {game}");
                        Console.WriteLine("Out of money!"); break;
                    }
                    else
                    {
                        Console.WriteLine("Too Expensive"); continue;
                    }
                }
                else if (game == "RoverWatch")
                {
                    if (balance > priceRW)
                    {
                        Console.WriteLine($"Bought {game}");
                        balance -= priceRW;
                        totalspent += priceRW;
                        
                    }
                    else if (balance == priceRW)
                    {
                        Console.WriteLine($"Bought {game}");
                        Console.WriteLine("Out of money!"); break;
                    }
                    else
                    {
                        Console.WriteLine("Too Expensive"); continue;
                    }
                }
                else if (game == "RoverWatch Origins Edition")
                {
                    if (balance > priceRWO)
                    {
                        Console.WriteLine($"Bought {game}");
                        balance -= priceRWO;
                        totalspent += priceRWO;
                        
                    }
                    else if (balance == priceRWO)
                    {
                        Console.WriteLine($"Bought {game}");
                        Console.WriteLine("Out of money!"); break;
                    }
                    else
                    {
                        Console.WriteLine("Too Expensive"); continue;
                    }
                }
                else if(game != "OutFall 4" && game != "CS: OG" && game != "Zplinter Zell" && game != "Honored 2" &&
                    game != "RoverWatch" && game != "RoverWatch Origins Edition" && game != "Game Time")
                {
                    Console.WriteLine("Not Found");
                }
                
                if (game=="Game Time")
                {
                    
                    Console.WriteLine($"Total spent: ${totalspent:F2}. Remaining: ${balance:F2}"); break;
                }
            }
        }
    }
}

100/100

 

0