# sum of arrays and printing even and odd numbers in the array

• November 8th, 2011, 10:19 AM
senecawolf
sum of arrays and printing even and odd numbers in the array
Call a method that computes the sum of the elements of the array. The header for this method is

public static int sumData(int num, int[] iArr, boolean DEBUG)

After the returning from the sumData method you will need to print out the int returned by the sumData method.

Then you will call a method that will print only the even numbers stored in the array. The header for this method is

public static void printEven(int num, int[] iArr, boolean DEBUG)

Then you will call a method that will print out the odd numbers stored in the array. The header for this method is

public static void printOdd(int num, int[] iArr, boolean DEBUG)
Detailed explanation: YES
Specific requirements:
The data in the arrays are generated at random and the array should be no bigger than 30. Pseudorandom integers should be between 10 and 90.
The program's output must be similar to this:

DEBUG
The location of array being added to the sum is 0.
The number added to sum is 95.
The current sum is 95.

DEBUG
The location of array being added to the sum is 1.
The number added to sum is 28.
The current sum is 123.

DEBUG
The location of array being added to the sum is 2.
The number added to sum is 47.
The current sum is 170.

DEBUG
The location of array being added to the sum is 3.
The number added to sum is 89.
The current sum is 259.

DEBUG
The location of array being added to the sum is 4.
The number added to sum is 98.
The current sum is 357.

The sum of the array is 357.

Even numbers in the array are:

DEBUG
The nummber in array location 0 is 95.

DEBUG
The nummber in array location 1 is 28.

DEBUG
The number is even.

intArr[1] = 28

DEBUG
The nummber in array location 2 is 47.

DEBUG
The nummber in array location 3 is 89.

DEBUG
The nummber in array location 4 is 98.

DEBUG
The number is even.

intArr[4] = 98

Odd numbers in the array are:

DEBUG
The nummber in array location 0 is 95.

DEBUG
The number is odd.

intArr[0] = 95

DEBUG
The nummber in array location 1 is 28.

DEBUG
The nummber in array location 2 is 47.

DEBUG
The number is odd.

intArr[2] = 47

DEBUG
The nummber in array location 3 is 89.

DEBUG
The number is odd.

intArr[3] = 89

DEBUG
The nummber in array location 4 is 98.
• November 8th, 2011, 10:40 AM
Norm
Re: sum of arrays and printing even and odd numbers in the array
Do you have a question? Do you have some code that you are having a problem with?
• November 8th, 2011, 01:57 PM
senecawolf
Re: sum of arrays and printing even and odd numbers in the array
Sorry about that! I need help completing it, I'm not quite sure how to add the sum of the array, or print out the even and odd numbers. My code needs to be similar to the DEBUG example given
• November 8th, 2011, 02:07 PM
Norm
Re: sum of arrays and printing even and odd numbers in the array
There are many people here that will help you write your code. You need to provide the effort to figure out your assignment and write some code. When you have problems, post them here.