I am learning java I am doing a program where I ask for 5 birthdays with name, month and day, and sort them according to the number of the year and numerically, at the moment I only have the days month and names in 3 different arrays and 3 cycles that run the arrays but I stagnate because when I run the program it goes well for all the arrays of names and days, when it comes to months ask for a month and then it goes on and on and asks for the 5 months and I want to have it ask for a name, day and month and so on until I complete the 5, this is my code.
import java.util.Arrays;
import java.util.Scanner;
public class birthday {
public static void main(String args[]){
Scanner input = new Scanner(System.in);
String[] words = new String[5];
int[] month = new int [5];
int [] num = new int[5];
for (int i = 0; i < words.length; i++) {
System.out.println("Birthday name?");
words[i] = input.next();
System.out.println(Arrays.toString(words));
for(int a = 0; a<num.length; a++) {
System.out.println("day ");
num[a] = input.nextInt();
System.out.println(Arrays.toString(num));
for(int x = 0; x < month.length; a++) {
System.out.println("number of month? ");
month[x] = input.nextInt();
System.out.println(Arrays.toString(month));
}
}
}
}
}
this is the the program since I ran it
Birthday name?
pepe
[pepe, null, null, null, null]
day
14
[14, 0, 0, 0, 0]
number of month?
8
[8, 0, 0, 0, 0]
number of month?
10
[8, 10, 0, 0, 0]
number of month?
11
[8, 10, 11, 0, 0]
number of month?
At the end only runs the last array that would be the month someone could help me as I can make one walk one by one (name, day, month, name, day month) so until the 5 thanks.