Results 21 to 26 of 26
 01222012, 10:00 PM #21
 Join Date
 Sep 2008
 Location
 Voorschoten, the Netherlands
 Posts
 13,939
 Blog Entries
 7
 Rep Power
 22
 01222012, 10:09 PM #22Member
 Join Date
 Oct 2011
 Posts
 18
 Rep Power
 0
Re: Getting the sum of the numbers in an array. Help Please!
thats embarrassing :/ haha well i took out one of those and it takes 3 inputs now, but only adds the last 2.
 01222012, 10:20 PM #23Member
 Join Date
 Oct 2011
 Posts
 18
 Rep Power
 0
Re: Getting the sum of the numbers in an array. Help Please!
I got it to work. Here's the code that made it work.
Java Code:import java.util.Scanner; public class Array2 { public static void main(String[]args) { Scanner sj = new Scanner(System.in); System.out.println("Please input your three numbers"); int[] numbers1 = new int[3]; numbers1[0] = sj.nextInt(); numbers1[1] = sj.nextInt(); numbers1[2] = sj.nextInt(); int sum = 0; for(int i = 0; i < numbers1.length; i++) { sum += numbers1[i]; } System.out.println("Here's the sum " + sum); } }

Re: Getting the sum of the numbers in an array. Help Please!
 01222012, 10:26 PM #25Member
 Join Date
 Oct 2011
 Posts
 18
 Rep Power
 0

Re: Getting the sum of the numbers in an array. Help Please!
Similar Threads

adding numbers in an array together
By pds8475 in forum New To JavaReplies: 3Last Post: 01222011, 08:23 PM 
Array of random numbers ...
By shane1987 in forum New To JavaReplies: 31Last Post: 11142010, 10:33 PM 
Swapping numbers in an array
By Awt582 in forum New To JavaReplies: 3Last Post: 11012010, 01:03 AM 
How do I place these numbers into an array
By mainy in forum New To JavaReplies: 2Last Post: 07192009, 06:57 PM 
Adding numbers in an array?
By hawaiifiver in forum New To JavaReplies: 9Last Post: 01222009, 04:50 AM
Bookmarks