Problem · Math
Calculate y/x using Patch
Learn this problemProblem statement
Given two integers y and x, compute y / x. The divisor x is nonzero.
Round the quotient to the nearest hundredth using round half up. An exact halfway value is rounded away from zero. Return the result as a string with exactly two digits after the decimal point. If the rounded magnitude is zero, return 0.00 without a negative sign.
Function
calculateRatio(y: int, x: int) → StringExamples
Example 1
y = 10x = 2return = "5.00"10 / 2 = 5, so the returned two-decimal string is 5.00.
Constraints
x != 0- Round to the nearest hundredth using round half up.
- Return exactly two digits after the decimal point.