Given a number n, return its string representation.

1
2
123 ⟹ '123'
123.456 ⟹ '123.456'
1
2
3
4
5
6
7
8
9
10
11
public class numberToString {

    public static String numberToString(int n) {
        return String.valueOf(n);
    }

    public static String numberToString(double n) {
        return String.valueOf(n);
    }

}

Tests

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import org.junit.*;
import static org.junit.Assert.*;

public class numberToStringTest {
    numberToString x = new numberToString();

    @Test
    public void testInt() {
        assertEquals(x.numberToString(123), "123");
    }

    @Test
    public void testDouble() {
        assertEquals(x.numberToString(123.456), "123.456");
    }

}