Question: use eclipse ( java project) create a method when user enter a positive number between 1 and 100 and then show message determine whether it

use eclipse ( java project) create a method when user enter a positive number between 1 and 100 and then show message determine whether it is even or odd

After that create Jnuit test case for this method, however I have EvenOrOddTest file, following below to create back above method ( like a constraint process )

all tests must be passed

class EvenOrOddTest {

/**

* Test the good case on an even number. This is a TDD test

* So we are going to expect the method to return the word even or the word odd

*/

@Test

void testEvenGood()

{

String result = EvenOrOdd.determineEvenOrOdd(80);

assertTrue(result.equals("even"));

}

/**

* Test the good case on an odd number. This is a TDD test

* So we are going to expect the method to return the word even or the word odd

*/

@Test

void testOddGood()

{

String result = EvenOrOdd.determineEvenOrOdd(81);

assertTrue(result.equals("odd"));

}

/**

* Tests that the number 1 will return odd as a lower boundary

*/

@Test

void testLowerBoundary()

{

String result = EvenOrOdd.determineEvenOrOdd(1);

assertTrue(result.equals("odd"));

}

/**

* Tests that the number 100 will return even as an upper boundary

*/

@Test

void testUpperBoundary()

{

String result = EvenOrOdd.determineEvenOrOdd(100);

assertTrue(result.equals("even"));

}

/**

* Tests that a number outside the upper range will return an error message

*/

@Test

void testOutsideRangeUpper()

{

String result = EvenOrOdd.determineEvenOrOdd(101);

assertTrue(result.equals("number out of range please enter a number between 1 and 100 inclusive"));

}

/**

* Tests that a number outside the lower range will return an error message

*/

@Test

void testOutsideRangeLower()

{

String result = EvenOrOdd.determineEvenOrOdd(0);

assertTrue(result.equals("number out of range please enter a number between 1 and 100 inclusive"));

}

}

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!