Eh made a program in java that makes the user enter a total number of numbers to evaluate, if you enter 4, you will have to enter 4 times any number, and then verify if it is even or not, one by one, but , when I try to deploy the succession of the pairs and inpairs, I only display the last value that I enter. How can I make the display something like this? Enter the number of numbers to be evaluated:
4
Enter num1:
2
Enter num2:
4
enter num3:
3
enter num4:
5
The even numbers are:
2, 4
The odd numbers are:
3, 5
int li, num;
System.out.println("Ingrese la cantidad de nuemros a evaluar: ");
Scanner sc = new Scanner(System.in);
li= sc.nextInt();
int np = 0;
int nip=05;
for(int i=1; i<=li; i++)
{
System.out.println("Ingrese su numero #" + i);
num = sc.nextInt();
if(num%2==0)
{
np = num;
}
else
{
nip= num;
}
}
System.out.println("Los numeros pares son: ");
System.out.println(np);
System.out.println("Los numeros inpares pares son: "+ nip);