java - how do I create a program that uses a for loop to print the first 1000 perfect squares? -
this have far. have write loop prints first 1000 perfect squares , determines time of execution. timer working don't know how show 1000 perfect squares.
public class whileloop { public static void main(string[] args) { long time_start, time_finish; time_start = time(); int i; for( =0; i< 1000; i++){ { system.out.print(""); } system.out.println(i);
}
time_finish = time(); system.out.println(time_finish - time_start + " milli seconds"); } public static long time(){ calendar cal = calendar.getinstance(); homecoming cal.gettimeinmillis(); }
}
you got break downwards problem 1 1. long story short... want following:
get start time: print 1*1 print 2*2 print 3*3 ... first 1000 squares print total execution timehere code snippits need work:
then using tools java provides... can
retrieve current time (store starttime variable) loop through 1000 elements , print results retrieve current time (compare starttime total runtime)i don't want give away much... provide force in right direction.
java loops for-loop
No comments:
Post a Comment