I need to save the data collected from the scanner input to use again throughout my code. For example, if someone enters the value one it gets saved into an array, and then afterward they enter the value 2 both should be saved into the array.
This is my code up until now:
public static void main(String[] args){
Scanner myObj = new Scanner(System.in);
System.out.println("Enter the customer name, the day of the booking, the month of the booking, and the number of people:");
String name = myObj.nextLine();
int day = myObj.nextInt();
int month = myObj.nextInt();
int number = myObj.nextInt();
int y = day;
int x = month;
if (y > 21 && x > 03) {
System.out.println("Upcoming bookings: ");
System.out.println("Customer name: " + name);
System.out.println("Date of booking: " + day + "/" + month);
System.out.println("Number of People: " + number);
}
else {
System.out.println("There are no upcoming bookings");
}
}
The idea is that the user can enter booking details but they only get displayed if the date has not passed, for that however, I need to be able to save all the inputs collected by the scanner.