-
Notifications
You must be signed in to change notification settings - Fork 0
/
College.java
71 lines (60 loc) · 2.2 KB
/
College.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
package Workshop.Sample;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class College {
public static void main(String[] args) {
Student obj1 = new Student();
Scanner input = new Scanner(System.in);
System.out.println("Enter no of teachers:");
int t = Integer.parseInt(input.nextLine());
Teacher[] A = new Teacher[10];
System.out.println("Enter no of students:");
int s = Integer.parseInt(input.nextLine());
Student[] B = new Student[10];
System.out.println("Enter details of teachers:");
for(int i = 0;i<t;i++){
System.out.print("Name: ");
String name = input.nextLine();
System.out.print("Age: ");
int age = Integer.parseInt(input.nextLine());
Teacher newTeacher = new Teacher(name,age);
A[i] = newTeacher;
}
System.out.println("Printing Teacher's Data: ");
for(int i=0;i<t;i++){
System.out.println("Name -> "+ A[i].name +" Age ->"+ A[i].age);
}
System.out.println("Enter details of students:");
for(int i=0;i<s;i++){
System.out.print("Name:");
String name = input.nextLine();
System.out.print("Age:");
int age = Integer.parseInt(input.nextLine());
Student newStudent = new Student(name,age);
B[i] = newStudent;
}
int max = B[0].marks;
int min = B[0].marks;
System.out.println("Now displaying result:");
for(int i=0;i<s;i++){
System.out.println("Name-> "+B[i].name+" Marks-> "+B[i].marks);
}
int flag = 0;
for(int i=0;i<s;i++) {
if (B[i].marks>max){
max = B[i].marks;
flag = i;
}
}
System.out.println("Student with highest marks: "+ B[flag].name);
flag = 0;
for(int i=0;i<s;i++) {
if (B[i].marks<min){
min = B[i].marks;
flag = i;
}
}
System.out.println("Student with lowest marks: "+ B[flag].name);
}
}