This document contains Java code that takes in 10 names as input, stores them in an array, takes in a name to search for, loops through the array to count how many times that name appears, prints out the full list of names and the count of how many times the searched name appeared.
This document contains Java code that takes in 10 names as input, stores them in an array, takes in a name to search for, loops through the array to count how many times that name appears, prints out the full list of names and the count of how many times the searched name appeared.
This document contains Java code that takes in 10 names as input, stores them in an array, takes in a name to search for, loops through the array to count how many times that name appears, prints out the full list of names and the count of how many times the searched name appeared.
for (int i = 0; i<l; i++) { System.out.println("Enter the input name: "+(i+1)); names[i] = scan.next(); } System.out.println("Enter name to find duplicate: "); String name = scan.next(); int repeated = 0;
for (int i = 0; i<l; i++) {
if(name.equalsIgnoreCase(names[i])) { repeated++; } } System.out.println("The "+l+" input names are: "); for (int i = 0; i<l; i++) { System.out.println(names[i]); } System.out.println("\n"+name+" appeared "+repeated+" times in the list."); }