r/javahelp • u/lunaticx995 • Jul 03 '23
Unsolved Arrays, please help
System.out.print("Enter number of boxes: ");
int boxes = scanner.nextInt();
String[] numberboxes = new String[boxes];
int[] gifts = new int[boxes];
for (int i = 0; i < boxes; i++) {
// Here is where I'm missing the code to show the number of the box the user will give the info
System.out.println("Box number" //the code to show box n1, then n2...etc until it reaches the number of boxes the user gave );
System.out.print("Gifts in the box: ");
gifts[i] = scanner.nextInt();Hello!! Above I copied the practice program i'm doing in java, working with arrays; I'd like to get info from every box, and show the box number i'm getting that info from, number that the user previously entered.
Thank you in advance. I'm a begginner so appologies if it is a dumb input i can't figure it out.
0
Upvotes
2
u/desrtfx Out of Coffee error - System halted Jul 04 '23
You don't need your
numberboxesvariable at all.Didn't it occur that the box number is just the loop index (and if you want to start it 1-based, add 1)?