I had an issue while trying to submit the ATM problem with this code:
public static void Main()
{
var nums = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
if(nums[0] % 5 == 0 && nums[0] + 0.5 <= nums[1])
Console.WriteLine((nums[1] - nums[0] - 0.5).ToString("0.00"));
else
Console.WriteLine(nums[1].ToString("0.00"));
}
I got a couple of times a runtime error and then I switched to this version of the code which basically does the same but it passed this time:
static void Main(string[] args)
{
var nums = Console.ReadLine().Split(' ');
var amount = int.Parse(nums[0]);
var balance = double.Parse(nums[1]);
if (amount % 5 == 0 && amount + 0.5 <= balance)
Console.WriteLine((balance - amount - 0.5).ToString("0.00"));
else
Console.WriteLine(balance.ToString("0.00"));
}