Problem · Math

Calculate y/x using Patch

Learn this problem
â—Ź EasyTwo Sigma logoTwo SigmaINTERNOA

Problem 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) → String

Examples

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.

More Two Sigma problems

drafts saved locally
public String calculateRatio(int y, int x) {
  // write your code here
}
y10
x2
expected"5.00"
checking account