I did not explain what I need to do very well. I will put the entire instructions, etc from the book. You see what I already have so far in the original post up above.

Straight from the book:

1. Create a java method called squared that uses a “for” loop to calculate and print n2.

2. Create a java method called exponential that uses a “for” loop to calculate and print 2n


Run each program for n = 1 to 20

Modify the timing.java program located below to use and test your methods at each value.

Graph the results in Excel and compare the running times.

timing.java program from book

Code:
/**
*** Measures the time of execution in Nanoseconds ***
***/

public class Timing {
	public static void main(String[] args){
		
		long start, end;
		double result,difference;
		
	   	for(int n=1; n<=20; n++){                                                                                                                                                                                                                                                                                                                                                                                                          
			//Calculate the Time for n^2.
		   	start = System.nanoTime();
			//Add code to call method to calculate n^2
			
		   	end = System.nanoTime();
		   	difference = (end - start);	
	
		}	
		
 	   	for(int n=1; n<=20; n++){   
		   //Calculate the Time for 2^n.
                                                                                                                                                                                                                                                                                                                                                                                                       
		   	start = System.nanoTime();
		  	//Add code to call method to calculate 2^n
			end = System.nanoTime();
			difference = (end - start);	
		
  	}
	}
	
// Add methods to calculate n^2 and 2^n	

	
}