View Single Post
  #1 (permalink)  
Old 07-23-2007, 08:34 PM
fegiflu fegiflu is offline
Member
 
Join Date: Jul 2007
Posts: 11
fegiflu is on a distinguished road
Help with setting number as even or odd
i have an input method to fill an array
it finds the total and the average of the numbers inputed, but i need a way for it to list out the even number and the odd numbers that were inputed, and then find the average of the even numbers and the odd numbers. can anyone help? here what i have so far

Quote:
public class SimplebutmethodicalArray2 {

public static void main(String[] args) {
int[] NumberList = new int[25];
double Sum = 0, Average;
int Count, Size, evennumbsum = 0, evenaverage;

Size = FillList(NumberList, 25);


for(Count = 0; Count < Size ; Count++)
System.out.println("NumberList[" + Count + "] = "+ NumberList[Count]);

for(Count = 0 ; Count < Size ; Count++)
Sum += NumberList[Count];
System.out.println("Total = " + Sum);
Average = Sum / Count;
System.out.println("Average = " + Average);


}

public static int FillList(int[] List, int MaxSize)
{
int K;
System.out.println("Enter Values Below, -99 to Stop");
for(K = 0 ; K < MaxSize ; K++)
{
System.out.print("Enter ");
List[K] = SimpleIO.inputInt();
if(List[K] == -99)
break;
}
return K;
}
}
Reply With Quote
Sponsored Links