Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Name: Rico P. Ceralbo Jr.

Year/Course/Section: 1BSCSA
Chapter 5 Activity
Code:

import java.util.Scanner;

public class TestProgram2 {

public static void main(String[] args) {

Scanner scan = new Scanner(System.in);

int l = 10;

String[] names = new String[l];


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.");
}

Output:

You might also like