Write a in java input 10 marks in an array of integers and 10 students name in another array of Strings. Input a number , search it in the marks array using linear search. If found then print the name of the student from the name array
Answers
Answered by
0
Answer:
what? I don't understand
Answered by
3
Program :
import java.util.*;
class Student
{
public static void main(String args[])
{
Scanner Sc = new Scanner(System.in);
int[] Marks = new int[10];
String[] Name = new String[10];
for(int i = 0 ; i < 10 ; i++)
{
System.out.print("Enter Name : ");
Name[i] = Sc.next();
System.out.print("Enter Marks : ");
Marks[i] = Sc.nextInt();
}
int n;
System.out.print("Enter a number : ");
n = Sc.nextInt();
for(int i = 0 ; i < 10 ; i++)
{
if(Marks[i]==n)
{
System.out.println(Name[i]);
}
}
}
}
Similar questions