import java.util.Scanner;
public class qstn_2
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of participants");
int n = sc.nextInt();
if(n<3 || n>11)
{
System.out.println("INPUT SIZE OUT OF RANGE");
System.exit(0);
}
String a[][] = new String[n][5];
for(int i=0;i<n;i++)
{
System.out.println("Participants "+(i+1));
for(int j=0;j<5;j++)
{
a[i][j] = sc.next();
}
}
System.out.println("\nKey : ");
String answer[] = new String[5];
for(int i=0;i<5;i++)
{
answer[i] = sc.next();
}
int score[] = new int[5];
int count = 0;
int insert = 0;
int max = 0;
for(int i=0;i<n;i++)
{
for(int j=0;j<5;j++)
{
if(a[i][j].equalsIgnoreCase(answer[j]))
{
count++;
}
}
if(max<count)
max = count;
score[insert++] = count;
count=0;
}
System.out.println();
for(int i = 0;i<n;i++)
{
System.out.println("Participants "+(i+1)+" = "+score[i]);
}
System.out.println("\nHighest Score :");
for(int i = 0;i<n;i++)
{
if(max==score[i])
System.out.println("Participant "+(i+1));
}
}
}
No comments:
Post a Comment