Софтуерно Инженерство
Loading...
Kamenpopov avatar Kamenpopov 0 Точки

Задача 3. Gaming Store - More Exercise: C# Intro and Basic Syntax (C# Fundamentals);

Здравейте, получавам 60/100 точки в Judge, бихте ли ми показали грешката?

https://pastebin.com/Hi9ptmck

3.Gaming Store

Write a program, which helps you buy the games. The valid games are the following games in this table:

Name

Price

OutFall 4

$39.99

CS: OG

$15.99

Zplinter Zell

$19.99

Honored 2

$59.99

RoverWatch

$29.99

RoverWatch Origins Edition

$39.99

On the first line, you will receive your current balance – a floating-point number in the range [0.00…5000.00].

Until you receive the command “Game Time”, you have to keep buying games. When a game is bought, the user’s balance decreases by the price of the game.

Additionally, the program should obey the following conditions:

  • If a game the user is trying to buy is not present in the table above, print “Not Found” and read the next line.
  • If at any point, the user has $0 left, print “Out of money!” and end the program.
  • Alternatively, if the user is trying to buy a game which they can’t afford, print “Too Expensive” and read the next line.
  • If the game exists and the player has the money for it, print “Bought {nameOfGame}”

When you receive “Game Time”, print the user’s remaining money and total spent on games, rounded to the 2nd decimal place.

Examples

Input

Output

120

RoverWatch

Honored 2

Game Time

Bought RoverWatch

Bought Honored 2

Total spent: $89.98. Remaining: $30.02

19.99

Reimen origin

RoverWatch

Zplinter Zell

Game Time

Not Found

Too Expensive

Bought Zplinter Zell

Out of money!

79.99

OutFall 4

RoverWatch Origins Edition

Game Time

Bought OutFall 4

Bought RoverWatch Origins Edition

Total spent: $79.98. Remaining: $0.01

Тагове:
0
C# Fundamentals
kkaraivanov avatar kkaraivanov 269 Точки

Провери този блок от проверката, мисля че е грешен

if (currentBalance >= gamePrice && command == "RoverWatch" || command == "RoverWatch Origins Edition" || command == "Honored 2" || command == "Zplinter Zell" || command == "CS: OG" || command == "OutFall 4")
                {
                    currentBalance -= gamePrice;
                    moneySpent += gamePrice;
                    Console.WriteLine($"Bought {command}");
                    if (currentBalance <= 0)
                    {
                        Console.WriteLine("Out of money!");
                        return;
                    }
 
                }
                else if (currentBalance < gamePrice)
                {
                    Console.WriteLine("Too Expensive");
                }              

принтирането на изхода - Console.WriteLine("Not Found");  би трябвало да е при проверката на игрите, не при образуване на цената

0
Kamenpopov avatar Kamenpopov 0 Точки

Мерси

0