Question: Java question on using API to implement isNan and isInfinity to pass the test. I'm a Java beginner. I'm given the task to implement isNan

Java question on using API to implement isNan and isInfinity to pass the test.

I'm a Java beginner. I'm given the task to implement isNan and isInfinity, but I have no idea how to do this with API.

Java question on using API to implement isNan and isInfinity to pass

The giving task is as follow:

the test. I'm a Java beginner. I'm given the task to implement

Here is the test so that it's convenient for you to copy and paste. Thank you.

@Test void should_judge_special_double_cases() { // Hint, please implement isInfinity and isNan in this class. assertTrue(isInfinity(1d / 0d)); assertTrue(isInfinity(-1d / 0d)); assertFalse(isInfinity(2d)); assertFalse(isInfinity(Double.NaN)); assertTrue(isNan(0d / 0d)); assertFalse(isNan(Double.NEGATIVE_INFINITY)); assertFalse(isNan(Double.POSITIVE_INFINITY)); }

@SuppressWarnings ("unused") private boolean isNan(double realNumber) { // TODO: // please implement the method to pass the test. It is better you call existing // API rather than implemented yourself. } /unused/ private boolean isInfinity(double realNumber) { // TODO: // please implement the method to pass the test. It is better you call existing // API rather than implemented yourself. } @Test void should_judge_special_double_cases() { // Hint, please implement isInfinity and isNan in this class. assertTrue(isInfinity( realNumber: 10 / 0d)); assertTrue(isInfinity( realNumber: -10 / d)); assertFalse(isInfinity( realNumber: 2d)); assertFalse(isInfinity (Double. NaN)); assertTrue(isNan( realNumber: d / d)); assertFalse(isNan(Double. NEGATIVE_INFINITY)); assertFalse(isNan(Double.POSITIVE_INFINITY)); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!