This is the actual problem that I am solving.
________________________________________________________________
Write a program that takes 10 integers as input. The program places the even integers into an array called evenLIst, the odd integers into an array called oddList, and the negative integers into an array called negativeList. The program displays the contents of the three arrays after all of the integers have been entered.
After I insert a negative integer, it places it under negative only. For an example, if I input -10, it only places it in the negativeList. But I want it to also put it in the evenList, hence it's negative and positive.
Here is my source code -----
<code>
import java.util.Scanner;
public class project8_1 {
public static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int even=0, odd=0, negative=0;
int evenList[] = new int[9];
int oddList[] = new int[9];
int negativeList[] = new int[9];
int count=0;
boolean valid = true;
for(count=0; count<10; count=count+1){
System.out.print("Enter an integer:");
valid = scan.hasNextInt();
while (valid==false){
System.out.println("Your entry was not a valid integer, please try again:");
scan.nextLine();
valid=scan.hasNextInt();
}
int x = scan.nextInt();
if (x<0){negativeList[negative]=x; negative=negative+1;}
if (x>=0 && x%2==0){evenList[even]=x; even=even+1;}
if (x>=0 && x%2==1){oddList[odd]=x; odd=odd+1;}
}
count=0;
System.out.println("Negative Numbers:");
while(count<negative){System.out.println(negativeList[count]+" "); count=count+1;}
count=0;
System.out.println("Even Numbers:");
while(count<even){System.out.println(evenList[count]+" "); count=count+1;}
count=0;
System.out.println("Odd Numbers:");
while(count<odd){System.out.println(oddList[count]+" "); count=count+1;}
Bookmarks