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
Module: C# Advanced 1
kkaraivanov avatar kkaraivanov 486 Точки

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

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