-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathInstitution_code.java
116 lines (108 loc) · 2.99 KB
/
Institution_code.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
//code to read values
Scanner sc=new Scanner(System.in);
Institution[] institution=new Institution[4];
Institution institute=new Institution(0,null,null,0,null);
for(int i=0;i<4;i++)
{
institution[i]=new Institution(sc.nextInt(), sc.next(), sc.next(), sc.nextInt(),sc.next());
}
String location1=sc.next();
int ans1=findNumClearancedByLoc(institution, location1);
System.out.println(ans1);
String institutionName2=sc.next();
sc.close();
institute=updateInstitutionGrade(institution, institutionName2);
if(institute!=null)
{
int x=(Integer.parseInt(institute.getNoOfStudentsPlaced())*100/(institute.getNoOfStudentsCleared()));
if(x>=80){
System.out.println("A" + x);
}
else{
System.out.println(x);
}
}
//code to call required method
//code to display the result
}
public static int findNumClearancedByLoc(Institution[] instArray, String location)
{
//method logic
int sum=0;
for(int j=0;j<4;j++)
{
if(instArray[j].getLocation().equalsIgnoreCase(location)){
sum=sum+instArray[j].getNoOfStudentsCleared();
}
}
return sum;
}
public static Institution updateInstitutionGrade(Institution[] instArray, String instName)
{
//method logic
Institution ins=new Institution(0,null,null,0,null);
for(int k=0;k<4;k++)
{
if(instArray[k].getInstitutionName().equalsIgnoreCase(instName)){
ins=instArray[k];
}
}
return ins;
}
}
class Institution
{
//code to build Institution class
private int institutionId;
private String institutionName;
private String noOfStudentsPlaced;
private int noOfStudentsCleared;
private String location;
private String grade;
public Institution(int institutionId, String institutionName, String noOfStudentsPlaced, int noOfStudentsCleared,String location)
{
this.institutionId = institutionId;
this.institutionName = institutionName;
this.noOfStudentsPlaced = noOfStudentsPlaced;
this.noOfStudentsCleared = noOfStudentsCleared;
this.location = location;
}
public void setInstitutionId(int institutionId) {
this.institutionId = institutionId;
}
public String getInstitutionName() {
return institutionName;
}
public void setInstitutionName(String institutionName) {
this.institutionName = institutionName;
}
public String getNoOfStudentsPlaced() {
return noOfStudentsPlaced;
}
public void setNoOfStudentsPlaced(String noOfStudentsPlaced) {
this.noOfStudentsPlaced = noOfStudentsPlaced;
}
public int getNoOfStudentsCleared() {
return noOfStudentsCleared;
}
public void setNoOfStudentsCleared(int noOfStudentsCleared) {
this.noOfStudentsCleared = noOfStudentsCleared;
}
public String getLocation() {
return location;
}
public void setLocation(String location) {
this.location = location;
}
public String getGrade() {
return grade;
}
public void setGrade(String grade) {
this.grade = grade;
}
}