forked from akhil-ghatiki/hacktoberfest-git-session
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathArray.java
42 lines (42 loc) · 1007 Bytes
/
Array.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
31
32
33
34
35
36
37
38
39
40
41
42
import java.util.*;
class Student{
int id ;
String name;
double avg;
Student(int id){
this.id = id;
}
Student(int id , String name )
{
this(id);
this.name= name;
}
Student (int id , String name , double avg){
this(id,name);
this.avg = avg;
}
void display( ){
System.out.println(id + " , " + name + ", " + avg);
}
}
public class Array {
public static void main(String args[]){
Scanner sc = new Scanner(System.in);
System.out.println("Enter the number of Students");
int n = sc.nextInt();
Student s[] = new Student[n];
for(int i=0; i<s.length ; i++)
{
System.out.println("Enter the Student Details of-> " +(i+1));
int x = sc.nextInt();
String str = sc.next();
double y = sc.nextDouble();
s[i] = new Student(x,str,y);
}
System.out.println("Enter the Average to display list ");
double p = sc.nextDouble();
for(int i=0; i< n ; i++)
if(s[i].avg >= p)
s[i].display();
}
}