-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathassignment_1.java
More file actions
56 lines (48 loc) · 1.38 KB
/
Copy pathassignment_1.java
File metadata and controls
56 lines (48 loc) · 1.38 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
import java.util.*;
class Student_assign {
int rno,age;
String name,phno;
float cgpa;
void read(Student_assign s) {
Scanner o=new Scanner(System.in);
System.out.println("Enter roll no : ");
this.rno=o.nextInt();
System.out.println("Enter Name : ");
this.name=o.next();
System.out.println("Enter Phone no : ");
this.phno=o.next();
System.out.println("Enter age : ");
this.age=o.nextInt();
System.out.println("Enter CGPA : ");
this.cgpa=o.nextFloat();
}
Student_assign() {
read(this);
}
}
class assignment_1 {
public static void main(String args[]) {
float r=0;
int l=0,n=0,a=0,o=50;
Student_assign s[]=new Student_assign[10];
for(int i=0;i<10;i++) {
s[i]=new Student_assign();
}
System.out.println("Data are:- ");
for(int i=0;i<10;i++) {
if(s[i].cgpa>r) {
r=s[i].cgpa;
l=i;
}
if((s[i].name.compareTo("Anu"))==0)
n=i;
if(s[i].age<o) {
o=s[i].age;
a=i;
}
}
System.out.println("Name of the student with highest CGPA : "+s[l].name);
System.out.println("Phone no. of ANU : "+s[n].phno);
System.out.println("Roll no. of youngest student : "+s[a].rno);
}
}