package problems.problem2;

import java.util.*;

/**
 * This class studies the efficiency of numberOfMarks.
 * 
 * 
 * @author carmocca 
 * @version (Abril 2016)
 */
public class numberOfMarksCost {

	//Change these values to test different array sizes
    private static int SIZE_INI = 100000;
    private static int SIZE_FIN = 1000000;
    private static int SIZE_INCR = 100000;

	//Mark to be beaten
    private static final int MARK = 50;
	//Maximum mark possible
    private static final int MAX_ARRAY = 100;
  
    public static void main(String args[]) {
        int [] vector;
        double t1, t2, time;
        t1 = t2 = time = 0;
        System.out.println("#---------------------------------------------");
        System.out.println("#         Measurement of search times: ");
        System.out.println("#          Marks from 0 to "+MAX_ARRAY+"    ");
        System.out.println("#--------------------------------------------- ");
        System.out.println("#    Size    Search time   Nº Marks > "+MARK+"   ");
        System.out.println("#---------------------------------------------");
        for (int t = SIZE_INI; t <= SIZE_FIN; t += SIZE_INCR) {
			vector = generateIncreasingRandoms(t, MAX_ARRAY);
			t1 = System.nanoTime();
			int n = CarlosImp.numberOfMarks(vector, MARK); //CHANGE CarlosImp TO THE CLASS THAT IMPLEMENTS ExamMarks
			t2 = System.nanoTime();
			time += t2 - t1;
			System.out.printf(Locale.US, " %1$8d %2$8.0f μs      %3$8d\n",
			    t, 
			    time / 1e3,
			    n);
        }
    }

	/**
	*	
	* @param amount "size of the array"
	* @param max "maximum possible number"
	* @return int "array of elements from 0 to max, with duplicates."
	*/
    public static int[] generateIncreasingRandoms(int amount, int max) {
        int[] randomNumbers = new int[amount];
        Random random = new Random();
        for (int i = 0; i < randomNumbers.length; i++) {
            randomNumbers[i] = random.nextInt(max);
        }
        Arrays.sort(randomNumbers);
        return randomNumbers;
     }
}

@@ -21,16 +21,49 @@
 blem2;%0A%0A
+import java.lang.reflect.Method;%0A
 import j
@@ -75,16 +75,17 @@
 til.*;%0A%0A
+%0A
 /**%0A * T
@@ -227,17 +227,20 @@
 Cost %7B%0A%0A
-%09
+    
 //Change
@@ -412,17 +412,20 @@
 00000;%0A%0A
-%09
+    
 //Mark t
@@ -476,17 +476,20 @@
 K = 50;%0A
-%09
+    
 //Maximu
@@ -594,24 +594,42 @@
 g args%5B%5D) %7B%0A
+        try %7B%0A    
         int 
@@ -639,16 +639,20 @@
 vector;%0A
+    
         
@@ -680,16 +680,20 @@
         
+ 
+   
 t1 = t2 
@@ -704,32 +704,36 @@
 me = 0;%0A        
+   
+ 
 System.out.print
@@ -728,32 +728,310 @@
 em.out.println(%22
+Write the name of the class that implements ExamMarks:%22);%0A            Scanner sc = new Scanner(System.in);%0A            Class%3C?%3E c = Class.forName(sc.nextLine());%0A            Method method = c.getMethod(%22numberOfMarks%22, int%5B%5D.class, int.class);%0A            System.out.println(%22%5Cn
 #---------------
@@ -1056,32 +1056,36 @@
 ------------%22);%0A
+    
         System.o
@@ -1139,32 +1139,36 @@
 es: %22);%0A        
+   
+ 
 System.out.print
@@ -1215,24 +1215,28 @@
 AY+%22    %22);%0A
+    
         Syst
@@ -1302,32 +1302,36 @@
 --- %22);%0A        
+ 
+   
 System.out.print
@@ -1387,32 +1387,36 @@
 %22   %22);%0A        
+  
+  
 System.out.print
@@ -1469,32 +1469,36 @@
 ----%22);%0A        
+    
 for (int t = SIZ
@@ -1537,19 +1537,32 @@
 INCR) %7B%0A
-%09%09%09
+                
 vector =
@@ -1603,19 +1603,32 @@
 ARRAY);%0A
-%09%09%09
+                
 t1 = Sys
@@ -1647,119 +1647,89 @@
 ();%0A
-%09%09%09int n = CarlosImp.numberOfMarks(vector, MARK); //CHANGE CarlosImp TO THE CLASS THAT IMPLEMENTS ExamMarks%0A%09%09%09
+                int n = (int) method.invoke(null, vector, MARK);%0A                
 t2 =
@@ -1748,19 +1748,32 @@
 Time();%0A
-%09%09%09
+                
 time += 
@@ -1781,19 +1781,32 @@
 2 - t1;%0A
-%09%09%09
+                
 System.o
@@ -1864,46 +1864,183 @@
 n%22,%0A
-%09%09%09    t, %0A%09%09%09    time / 1e3,%0A%09%09%09    n
+                        t,%0A                        time / 1e3,%0A                        n);%0A            %7D%0A        %7D catch (Exception ex)%7B%0A            System.out.println(%22ERROR%22
 );%0A 
@@ -2059,18 +2059,27 @@
  %7D%0A%0A
-%09/**%0A%09*%09%0A%09
+    /**%0A    *%09%0A    
 * @p
@@ -2110,17 +2110,20 @@
  array%22%0A
-%09
+    
 * @param
@@ -2153,17 +2153,20 @@
 number%22%0A
-%09
+    
 * @retur
@@ -2223,17 +2223,20 @@
 cates.%22%0A
-%09
+    
 */%0A    p

Update numberOfMarksCost.java