void testMethods(){ System.out.println("Version 5. .") ; int correct = 0 ; int wrong = 0 ; int[] oneTo4= {1 , 2 , 3 , 4 } ; int sumN1 =sumEveryN(oneTo4, 2); // if( sumN1 == 4) { correct++; } else { wrong++; printp("sumEveryN({1 , 2 , 3 , 4 }, 2) wrong"); } //douuble arr: String[] str1 = {"a1","b2","c"} ; String[] res = doubleArr(str1); //printp(Arrays.toString(res)); if( res[0].equals("a1") && res[1].equals("a1") && res[2].equals("b2") && res[3].equals("b2") && res[4].equals("c") && res[5].equals("c") ) correct++; else { wrong++; printp( "doubleArr({a1,b2,c}) wrong" ); } if(indexOf5(oneTo4) == -1) correct++; else { wrong++; printp( "indexOf5({1 , 2 , 3 , 4 } ) wrong" ); } int[] five0= {5 , 5 , 3 , 4 } ; if(indexOf5(five0) == 0) correct++; else { wrong++; printp( " indexOf5({5 , 5 , 3 , 4 }) wrong ") ; } if(indexOf(five0, 5) == 0) correct++; else { wrong++; printp( " indexOf({5 , 5 , 3 , 4 }, 5) wrong ") ; } if(indexOf(oneTo4, 2) == 1) correct++; else { wrong++; printp( " indexOf({1 , 2 , 3 , 4 } ,2) wrong ") ; } if(indexOf(oneTo4, 999) == -1) correct++; else { wrong++; printp( " indexOf({1 , 2 , 3 , 4 }, 999 ) wrong ") ; } int[] x1 = { 2 , 18 , 22, 4 , 6 } ; if(secondSmallest(x1) == 4) correct++; else { wrong++; printp("secondSmallest({ 2 , 18 , 22, 4 , 6 }) wrong"); } int[] negx1 = { -2 , -18 , -22, -4 , -6 } ; if(secondSmallest(negx1) == -18) { correct++; } else { wrong++; printp("secondSmallest({ -2 , -18 , -22, -4 , -6}) wrong"); } int[] res2 = randos(2,20, 100) ; int itWas = res2[0]; boolean isCorrect = true; boolean isDiff = false; for( int i = 1 ; i < res2.length ; i++) { int r = res2[i]; // printp("r: " + r); if(r != itWas) isDiff= true; if( r < 2 || r > 20){ isCorrect = false; } itWas = r; } if(isCorrect && isDiff) correct++; else { wrong++; printp("randos(2,20, 100) wrong, details: ") ; printp("-----------------------") ; if(isCorrect) printp( "\t correct range of values") ; else printp( "\t wrong range of values") ; if(isDiff == false) printp( "\t ALl of your values are the exact same random number. Make sure that each element in the array attempts to create a ne method...") ; printp("-----------------------") ; } // mean between // int[] arr = {1,1,2,3,4}; if (meanBetween(arr, 1,4) == 2.5){ correct++; } else { wrong++; printp("meanBetween(arr, 1,4) wrong"); } if (meanBetween(arr, 1,4) == 2.5){ correct++; } else { wrong++; printp("meanBetween(arr, 1,4) wrong"); } int[] arr2= {1,5,20,30,90}; if (meanBetween(arr2 , 5, 90) == 25){ correct++; } else { wrong++; printp("meanBetween( { 1,5,20,30,90} , 5, 90 ) wrong"); } if(isPalindromic(new int[]{1,2,1})) correct++; else { wrong++; printp("isPalindromic(new int[]{1,2,1}) wrong"); } if(isPalindromic(new int[]{1,2,2,1})) correct++; else { wrong++; printp("isPalindromic(new int[]{1,2, 2,1}) wrong"); } if(isPalindromic(new int[]{1,2,3,2,1})) correct++; else { wrong++; printp("isPalindromic(new int[]{1,2, 3, 2,1}) wrong"); } if(isPalindromic(new int[]{1,2,3,1,1})==false) correct++; else { wrong++; printp("isPalindromic(new int[]{1,2,3,1,1}) wrong"); } //big lists int size = 90; int[] a1 = new int[size*2]; int max = size ; for(int i = 0 ; i< size ;i++){ a1[i]= i + 1; } for(int i = 0 ; i< size ;i++){ a1[i+size]= max--; } if(isPalindromic(a1 ) ) correct++; else { wrong++; printp("isPalindromic(long list 1 ) wrong"); } //results: printp("\n---------------\n Results:"); printp("\t Number Correct: " + correct); printp("\t Number wrong : " + wrong); } void printp(String s){ System.out.println(s); } void printp(int s){ System.out.println(s); }