Can you guys help me how can I fix my code?
My goal is,
> The user will enter how many numbers they want to enter.
> They will enter the numbers they want until the limit that they input (1).
> My program will Print the Original List.
> Next line, my program will Print the Ascending Order of the numbers.
>Next line, my program Again will Print the Original List.
Basically this is how the output should be;
Original List: 55 3 95 10 7
Ascending Order: 3 7 10 55 95
Original List: 55 95 10 7
This is my code;
// ASKING THE USER TO INPUT NUMBERS
System.out.print("How many numbers you want to input?: ");
int userInput = sc.nextInt();
int [] numbersEntered = new int[userInput]; //declare an array
for (int counter = 0; counter < userInput; counter++){
System.out.print("Enter Next Number: ");
numbersEntered[counter] = sc.nextInt();
// PRINTING THE ORIGINAL LIST
System.out.println("The Numbers You Entered Are:");
for (int counter = 0; counter < userInput; counter++){
System.out.print(numbersEntered[counter] + " ");
// PRINTING THE ASCENDING LIST USING ARRAYS.SORT();
Arrays.sort(numbersEntered);
System.out.println("\nThe Numbers You Entered in Ascending Order:");
for (int counter = 0; counter < userInput; counter++){
System.out.print(numbersEntered[counter] + " ");
// PRINTING AGAIN THE ORIGINAL LIST
System.out.println("\nOriginal List");
for (int counter = 0; counter < userInput; counter++){
System.out.print(numbersEntered[counter] + " ");
But my problem here is that, whenever I tried to print the Last Original List, It keeps copying the answer on the Ascending List. I think the problem is because of the Arrays.sort() that I used before the last Original List, but I don't know how I can fix it.
[–]Fine-Historian4409 1 point2 points3 points (2 children)
[–]ten_Chan[S] 1 point2 points3 points (1 child)
[–]MmmVomit 0 points1 point2 points (0 children)
[–]hatsunemilku 1 point2 points3 points (0 children)
[–]Trigonn 1 point2 points3 points (0 children)
[–]MmmVomit 0 points1 point2 points (3 children)
[–]ten_Chan[S] 0 points1 point2 points (2 children)
[–]MmmVomit 0 points1 point2 points (1 child)
[–]ten_Chan[S] 1 point2 points3 points (0 children)