×

# [closed] C# ATM Problem [HS08TEST] - Runtime Error(NZEC)

 0 ATM problem on C# My code is: using System; public class Test { public static void Main() { int x = int.Parse(Console.ReadLine()); double y = double.Parse(Console.ReadLine()); if ((y - x > 0.5) && x % 5 == 0) { Console.WriteLine((y - x - 0.5).ToString("0.00")); } else { Console.WriteLine(y.ToString("0.00")); } } }  asked 14 Nov '13, 03:35 0★proka 1●1●1●1 accept rate: 0% 4★kunal361 6.0k●13●32●72

### The question has been closed for the following reason "The question is answered, right answer was accepted" by kunal361 14 Nov '13, 15:58

 2 this is ur corrected code...the 2 inputs are in the same line hence ur console.ReadLine() reads 2 space separated numbers....hence u need to split the string using the Split() function... using System; public class Test { public static void Main() { string s=Console.ReadLine(); string[] s1=s.Split(' '); int x = int.Parse(s1[0]); double y = double.Parse(s1[1]); if ((y - x >= 0.5) && x % 5 == 0) { Console.WriteLine((y - x - 0.5).ToString("0.00")); } else { Console.WriteLine(y.ToString("0.00")); } } }  answered 14 Nov '13, 08:45 4★kunal361 6.0k●13●32●72 accept rate: 21%
 0 Thanks bro', that did the trick! Didn't pay too much attention, it seems :) answered 14 Nov '13, 12:46 0★proka 1●1●1●1 accept rate: 0% glad could help...:) (14 Nov '13, 15:58) kunal3614★

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×532
×422
×190
×59
×41

question asked: 14 Nov '13, 03:35

question was seen: 3,707 times

last updated: 14 Nov '13, 15:58