ATM NZEC C#

using System;
class t2
{
public static void Main()
{
double x=double.Parse(Console.ReadLine());
double y=double.Parse(Console.ReadLine());
if (x%5==0)
if (x>y)
if (y-x<0.5)
Console.WriteLine((y-x)-0.5);
else Console.WriteLine(y);
}
}

keeps doing runtime error NZEC this is in C#

thanks in advance

the error is the way u take the input…the two numbers are in the same line…

eg…

300 120.00

now when u do…

Console.ReadLine()

the input that is taken is the whole line…i.e…

300 120.00

now when u do…

double.Parse();

it gives a number format exception as there is a space in the string…so before doing double.Parse() u need to split the input according to the space…i.e.

string temp = Console.ReadLine();
double x=double.Parse(temp.Split(' ')[0]);
double y=double.Parse(temp.Split(' ')[1]);

this should be it…hope this helps…:slight_smile:

also u sould check ur if conditions…maybe they arent correct…they may not cause a NZEC…but a WA maybe on the cards…:stuck_out_tongue: