Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David Kroenke, David J. Auer

3rd Edition

0131986252, 978-0131986251

More Books

Students also viewed these Databases questions

Question

Define Administration?

Answered: 1 week ago