Advertisement
therrontelford

Sum an Array

Jan 31st, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.20 KB | None | 0 0
  1. public class sum{
  2.     public static void main(String[] args) {
  3.    
  4.     double[] array = {1.2,2.3,3.4,4.5,5.6,6.7,7.8,8.9,9.1};
  5.     double sum = 0;
  6.  
  7.     for (int i=0; i<array.length; i++) {
  8.         sum+= array[i];
  9. }
  10. }
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement