(Runtime error) На задача 02. Exam Preparation, от упражнението за while-loops.
Кода работи правилно според примерните вход и изход данени в лаб-а, в Judge обче ми дава 50/100. На 5 от тестовете ми дава следното нещо:
Unhandled Exception: System.ArgumentNullException: Value cannot be null. Parameter name: value at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt) at ExasPreparation.Program.Main(String[] args)
Променях кода цял следобед, но както и да го напиша Runtime error-a не се маха. Благодаря предварително!
using System;
namespace ExasPreparation
{
class Program
{
static void Main(string[] args)
{
int gameOver = int.Parse(Console.ReadLine());
string command = string.Empty;
double fails = 0;
double counterExams = 0;
double gradesCombine = 0;
string prevComand = "";
while (command != "Enough")
{
if (command != "Enough")
{
prevComand = command;
}
double currentGrade = 0;
command = Console.ReadLine();
if (command == "Enough")
{
break;
}
currentGrade = double.Parse(Console.ReadLine());
if (currentGrade < 4.00)
{
fails++;
}
if (fails == gameOver)
{
Console.WriteLine($"You need a break, {fails} poor grades.");
}
counterExams++;
gradesCombine = gradesCombine + currentGrade;
}
Console.WriteLine($"Average score: {(gradesCombine / counterExams):f2}\nNumber of problems: {counterExams}\nLast problem: {prevComand}");
}
}
}