Write a program to accept the name of 20 students along with their marks obtained in‘Computer Applications’ in the final examinations in 2 single dimensional arrays. Display the name of the student getting the highest mark along with the name.
(import java.util.Scanner;)
Answers
Answered by
2
Explanation:
import java.util.Scanner;
class Solution
{
public static void main (String arr[])
{
Scanner sc = new Scanner (System.in);
String [] name = new String [20];
int [] marks = new int[20];
for( int i=0;i<20;i++)
{
name[i] = sc.nextLine();
}
for( int i=0;i<20;i++)
{
marks[i] = sc.nextInt();
}
int maxMarks = marks[0];
int index = 0;
for( int i=1;i<20;i++)
{
if(maxMarks < marks[I])
{
maxMarks = marks[i];
index =i;
}
}
System.out.println(name[index] + " : " + maxMarks );
}
}
Similar questions