Question: I need help making J UNIT Test Data for the code below: public class ArrayCheckSchlemme { public static void main(String[] args) { int newArray =

I need help making J UNIT Test Data for the code below:

public class ArrayCheckSchlemme {

public static void main(String[] args) { int newArray = 5; int arrayMinimum = 1; int arrayMaximum = 100; int elements[] = new int[newArray];

for (int i = 0; i < elements.length; i++) //for loop to add in random #'s between 1-100 elements[i] = (int) (Math.random() * (arrayMaximum - arrayMinimum + 1)) + arrayMinimum;

System.out.print("All Elements: "); for (int i : elements) System.out.print(i + " "); System.out.println();

System.out.print("All Elements Reversed: "); for (int i = elements.length - 1; i >= 0; i--) System.out.print(elements[i] + " "); System.out.println();

System.out.println("First Element: " + elements[0]); System.out.println("Last Element: " + elements[elements.length - 1]);

System.out.print("Odd Indexed Elements: "); for (int i = 1; i < elements.length; i += 2) System.out.print(elements[i] + " "); System.out.println();

System.out.print("Odd Elements: "); for (int i = 0; i < elements.length; i++) //loop to determine odd integers by dividing by 2 if (elements[i] %2 != 0) System.out.print(elements[i] + " "); System.out.println();

System.out.println("Highest Element: " + highestElement(elements)); System.out.println("Lowest Element: " + lowestElement(elements)); }

public static int highestElement(int arrayHighest[]) { //loops to determine the highest and lowest element in the array int highestElement = arrayHighest[0]; for (int i = 1; i < arrayHighest.length; i++) if (arrayHighest[i] > highestElement) highestElement = arrayHighest[i]; return highestElement; }

public static int lowestElement(int arrayLowest[]) { int lowestElement = arrayLowest[0]; for (int i = 1; i < arrayLowest.length; i++) if (arrayLowest[i] < lowestElement) lowestElement = arrayLowest[i]; return lowestElement; } }

Step by Step Solution

3.42 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

To create JUnit test data for the ArrayCheckSchlemme class you can write test cases to verify the fu... View full answer

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 Programming Questions!