You are not logged in. Please login at www.codechef.com to post your questions!

×

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

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

proka's gravatar image

0★proka
1111
accept rate: 0%

closed 14 Nov '13, 15:58

kunal361's gravatar image

4★kunal361
6.0k133272

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


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"));
        }
    }
}
link

answered 14 Nov '13, 08:45

kunal361's gravatar image

4★kunal361
6.0k133272
accept rate: 21%

edited 14 Nov '13, 08:45

Thanks bro', that did the trick! Didn't pay too much attention, it seems :)

link

answered 14 Nov '13, 12:46

proka's gravatar image

0★proka
1111
accept rate: 0%

glad could help...:)

(14 Nov '13, 15:58) kunal3614★

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • 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