-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
62 lines (62 loc) · 1.44 KB
/
Copy pathStudent.java
File metadata and controls
62 lines (62 loc) · 1.44 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import java.util.Scanner;
class Student
{
int rollno;
String fname;
String lname;
String year;
Student()
{
this.rollno=0;
this.fname="";
this.lname="";
this.year="";
}
Student(int a,String fname,String lname,String year)
{
this.rollno=a;
this.fname=fname;
this.lname=lname;
this.year=year;
}
void display()
{
System.out.println("Rollno is : "+this.rollno);
System.out.println("Student first name : "+this.fname);
System.out.println("Student last name : "+this.lname);
System.out.println("Student year "+this.year);
}
public static void main(String[] args)
{
Scanner sc= new Scanner(System.in);
System.out.println("Please enter how many student detail want to enter");
int n=sc.nextInt();
Student[] S=new Student[n];
for(int i=0;i<n;i++)
{
System.out.println("Please enter roll no : ");
int r=sc.nextInt();
String f=sc.nextLine();
System.out.println("Please enter student first name :");
f=sc.nextLine();
System.out.println("Please enter student last name : ");
String l=sc.nextLine();
System.out.println("Please enter student year :");
String y=sc.nextLine();
S[i]=new Student(r,f,l,y);
}
for(int i=0;i<n;i++)
{
S[i].display();
}
System.out.println("Please enter which class you want");
String cyear=sc.nextLine();
for(int i=0;i<n;i++)
{
if(S[i].year.equals(cyear))
{
S[i].display();
}
}
}
}