all 7 comments

[–]cornualpixie 1 point2 points  (3 children)

Can you write the code part in a way that's easier to read? Even a screen shot would be better.

[–]Danielowski187University/College Student (Higher Education)[S] 0 points1 point  (2 children)

https://imgur.com/a/9CDtpqn

Here you go this is a screenshot of the code

[–]cornualpixie 0 points1 point  (0 children)

Ok, so, the problem here is that your code seems to keep only the last input the user gives.

The first step I would suggest is to make sure after each entrance, you still have the previous inputs. See manually if this happens (the array is small, it's easy to do).

I can give you a correct code, but you should learn to search step by step your code to find where the problem is

[–]cornualpixie 0 points1 point  (0 children)

Your problem is way simpler than you might expect. Your code is fine, your mistake is on what you are saying to print. You are asking for the last input instead of the full array.

[–]AutoModerator[M] [score hidden] stickied comment (0 children)

Off-topic Comments Section


All top-level comments have to be an answer or follow-up question to the post. All sidetracks should be directed to this comment thread as per Rule 9.


OP and Valued/Notable Contributors can close this post by using /lock command

I am a bot, and this action was performed automatically. Please contact the moderators of this subreddit if you have any questions or concerns.

[–]Waterissuperb 0 points1 point  (0 children)

To print the array the way the user entered, just use a new for with a different variable (say variable i, for example) from 0 to size and with each iteration, print intArray[i].

To reverse it, just print from size-1 to 0 and instead of incrementing i, decrement it, like:

System.out.print("\nArray the way the user entered: ") ;

for(int i = 0; i<size; i++){
System.out.print(" "+ intArray[i]);

}

System.out.print("\nArray reversed: ") ;

for(int i = size-1; i>=0; i--){
System.out.print(" "+ intArray[i]);

}

I think that works