View Full Version : Problem regarding Arrays

12-04-2009, 12:12 AM
Hey, I'm working on a problem and what I need the program to do is to add up the numbers in the array NOT add up how many numbers there are. There are 5 total numbers that a user will input. The counting of the numbers will be in a seperate method which will then return to the main. Then be displayed through system.out.println. I don't know where I am going wrong any help? Thanks!

import javax.swing.*;
import java.util.*;
public class Question10 {

public static void main (String []args) {

Scanner keyboard = new Scanner(System.in);

int [] myNums = new int[5];
for (int i=0; i < myNums.length; i++) {
System.out.println ("Please Enter Data");
myNums[i]= keyboard.nextInt();

} //end main

public static int getTotal(int inArray) {

int a,b,c,d,e,f;
f = a+b+c+d+e;

return f;

}//end class

12-04-2009, 12:32 AM
java != javascript

Ask the mods to move this thread to the appropriate forum.