By TopCoder* USA
Often, when we round a real valued number to an integer, we round up if the fractional part is 0.5 or greater, and down if the fractional part is less than 0.5. In this problem, you have to write a method round, which takes a real valued number as a String, num, and a cutoff as a String, cutoff. cutoff will be formatted exactly as "0.####", where each '#' represents a digit ('0'-'9'). At least one of the digits to the right of the decimal point in cutoff will be non-zero. Your task is to round num up if its fractional part is greater than cutoff, and down otherwise, and return the result as an int. To avoid issues with double imprecision, the fractional part of num will not be exactly equal to cutoff. Hence, the traditional rounding method described in the opening sentence would be represented by cutoff = "0.5000".
The input contains several test cases. Each one is given in two lines. The num string is at the first line and the cutoff is at the second line. num will be a sequence of one or more digits ('0'-'9'), with an optional decimal point ('.'). num will contain between 1 and 10 characters, inclusive. cutoff will be formatted exactly as "0.####", where each '#' represents a digit ('0'-'9'). The fractional part of num will NOT be exactly equal to cutoff.
The input is terminatted by EOF.
Your program should output one line to each test case. This line contains only the integer part of num rounded up or down according to the given cutoff.
|Sample Input||Sample Output|