Assessment 3_13_sample
Instructions
This assessment is designed to be completed in 10 minutes or less.
Copy the template below and get all the test cases to pass. Hard-coding answers will not receieve credit; your solution must work for valid arrays.
The problem
Imagine the user enters two lists of integers. Return a the largest number between the two arrays. For example, if the two input arrays were [1, 3, 2]
and [7, 4]
, your code would return 7
. If both arrays are empty, return 0
.
Code Template and Test cases
public class Assess3_13_Sample{
public static int findMax(int[] arr1, int[] arr2){
return -9999;
}
public static void main(String[] args){
int [] arr1a = {};
int [] arr1b = {};
System.out.println("test1: " + (findMax(arr1a, arr1b) == 0));
int [] arr2a = {-99999};
int [] arr2b = {};
System.out.println("test2: " + (findMax(arr2a, arr2b) == -99999));
int [] arr3a = {1, 3};
int [] arr3b = {2};
System.out.println("test3: " + (findMax(arr3a, arr3b) == 3));
int [] arr4a = {2, 1, 3};
int [] arr4b = {7, 8, 6, 4, 5};
System.out.println("test4: " + (findMax(arr4a, arr4b) == 8));
int [] arr5a = {1, 2, 3, 3};
int [] arr5b = {4};
System.out.println("test5: " + (findMax(arr5a, arr5b) == 4));
int [] arr6a = {};
int [] arr6b = {1, 3};
System.out.println("test6: " + (findMax(arr6a, arr6b) == 3));
}
}