FindSumAndAverage

From ggc

Jump to: navigation, search

01 /**
02  * All about my application here.
03  @author Jam Jenkins
04  */
05 public class FindSumAndAverage
06 {
07   public static void main(String[] args)
08   {
09     int[] nums={36526714523, -261};
10     double sum=0;
11     System.out.println("Starting sum: "+sum);
12     for(int i=0; i<nums.length; i++)
13     {
14       System.out.println("Looking at: "+nums[i]);
15       sum+=nums[i];
16       System.out.println("Sum is now "+sum);
17     }
18     System.out.println("Finally, the sum is "+sum);
19     double average=sum/nums.length;
20     System.out.println("Finally, the average is "+average);
21   }
22 }


Download/View FindSumAndAverage.java





Views
Personal tools
Add to 
del.icio.usAdd to 
diggAdd to 
FacebookAdd to 
favoritesAdd to 
GoogleAdd to 
MySpaceAdd to 
PrintAdd to 
SlashdotAdd to 
StumbleUponAdd to 
Twitter