-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArraySearch.java
30 lines (30 loc) · 919 Bytes
/
ArraySearch.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
package Arrays;
import java.util.Scanner;
public class ArraySearch {
public static void main (String[]args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter percentage of topper : ");
double pT = sc.nextDouble();
String names[]= new String[20];
double marks[]= new double[20];
boolean flag=false;
for (int k=0;k<20;k++){
System.out.println("Enter Name : ");
names[k]=sc.nextLine();
System.out.println("Enter Percentage : ");
marks[k]=sc.nextDouble();
}
for (int i=0;i<20;i++){
if (pT==marks[i] ){
System.out.println("Percentage of topper found ");
System.out.println("Name : "+names[i]);
System.out.println("Percentage : "+marks[i]);
flag=true;
break;
}
}
if (flag==false)
System.out.println("Percentage of topper not found ");
sc.close();
}
}