When submitting this lab, submit a .java file called ArrayListDup, and create the following structure in Eclipse: Add a
Posted: Mon Jun 06, 2022 11:15 am
When submitting this lab, submit a .java file called ArrayListDup, and create the following structure in Eclipse:
Add a method to your previous lab (the ArrayList lab) called dups, that you call from main(), passing your ArrayList as an argument. The dups() method will not modify your original ArrayList but will return a new ArrayList containing all the duplicate numbers in the first ArrayList. Each duplicate value should only appear once in your ArrayList of duplicates.
This program will ask the user to enter a series of numbers.The user may enter as many numbers as they wish, hitting the enter key with no data when they wish to stop.The program will then display the array of numbers and the sum total of those numbers.
Please enter a number (or just hit enter to finish): 1Please enter a number (or just hit enter to finish): 2Please enter a number (or just hit enter to finish): 3Please enter a number (or just hit enter to finish): 2Please enter a number (or just hit enter to finish): 4Please enter a number (or just hit enter to finish): 2Please enter a number (or just hit enter to finish): 5Please enter a number (or just hit enter to finish): 2Please enter a number (or just hit enter to finish): 6Please enter a number (or just hit enter to finish): 4Please enter a number (or just hit enter to finish): 7Please enter a number (or just hit enter to finish): 4Please enter a number (or just hit enter to finish): Index Item0 11 22 33 24 45 26 57 28 69 410 711 4There are 12 items in the ArrayList.The sum total of numbers in the ArrayList is 42.The following numbers were duplicated in the ArrayList: [2, 4].
Do you wish to play again? (Y/N): n
Add a method to your previous lab (the ArrayList lab) called dups, that you call from main(), passing your ArrayList as an argument. The dups() method will not modify your original ArrayList but will return a new ArrayList containing all the duplicate numbers in the first ArrayList. Each duplicate value should only appear once in your ArrayList of duplicates.
This program will ask the user to enter a series of numbers.The user may enter as many numbers as they wish, hitting the enter key with no data when they wish to stop.The program will then display the array of numbers and the sum total of those numbers.
Please enter a number (or just hit enter to finish): 1Please enter a number (or just hit enter to finish): 2Please enter a number (or just hit enter to finish): 3Please enter a number (or just hit enter to finish): 2Please enter a number (or just hit enter to finish): 4Please enter a number (or just hit enter to finish): 2Please enter a number (or just hit enter to finish): 5Please enter a number (or just hit enter to finish): 2Please enter a number (or just hit enter to finish): 6Please enter a number (or just hit enter to finish): 4Please enter a number (or just hit enter to finish): 7Please enter a number (or just hit enter to finish): 4Please enter a number (or just hit enter to finish): Index Item0 11 22 33 24 45 26 57 28 69 410 711 4There are 12 items in the ArrayList.The sum total of numbers in the ArrayList is 42.The following numbers were duplicated in the ArrayList: [2, 4].
Do you wish to play again? (Y/N): n