-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtemp.java
257 lines (197 loc) · 7.77 KB
/
temp.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
import java.util.Arrays;
import java.util.Scanner;
public class temp {
public static float percentage(float[] per){//1
float x=0;
for(int i=0;i<8;i++){//2
if(per[i]>0 && per[i]<=100){
x=x+per[i];
}//3
}//2
return x;
}//1
public static void Output(float[] gpa,String[] op, int total, String[] enrolment_number){
System.out.println("\n\nUva Wellassa University of Sri Lanka");
System.out.println("\t\tResults\n\n");
System.out.print("Enrolment number ");
System.out.print("GPA ");
System.out.println("Selected Discipline");
for(int i=0;i<total;i++){
System.out.printf(enrolment_number[i]);
System.out.print(" ");
System.out.print(gpa[i]);
System.out.print(" ");
System.out.printf(op[i]);
System.out.printf("\n");
}
}
public static String[] Process(float[] a, float[] b, int c, int[][] cor, String[] eng_types, int[] number){//4 //temp returning float array
int j=0;
int[] d= new int[8];
//d[0]=d[1]=d[2]=d[3]=d[4]=d[5]=d[6]=d[7]=1;
String[] output = new String [c];
for(int i=0;i<c;i++){//1
int l=0;
for(j=0;j<c;j++){
if(a[i]==b[j]){ //this will give the index of input
int e=cor[j][l];
for(int element: number){
System.out.print(element);
}
System.out.print(j);
System.out.print(l);
System.out.print("dsdd");
switch(e) {
case 1:{
if(d[0]<=number[0]){
output[i]=eng_types[0];
d[0]++;
System.out.print("dsdddd");
}
else{
l++;
continue LOOP;
}
break;
}
case 2:{
int d2=1;
if(d[1]<=number[1]){
output[i]=eng_types[1];
d[1]++;
}
else{
l++;
continue LOOP;
}
break;
}
case 3:{
if(d[2]<=number[2]){
output[i]=eng_types[2];
d[2]++;
break;
}
else{
l++;
continue LOOP;
}
}
case 4:{
if(d[3]<=number[3]){
output[i]=eng_types[3];
d[3]++;
break;
}
else{
l++;
continue LOOP;
}
}
case 5:{
if(d[4]<=number[4]){
output[i]=eng_types[4];
d[4]++;
break;
}
else{
l++;
continue LOOP;
}
}
case 6:{
if(d[5]<=number[5]){
output[i]=eng_types[5];
d[5]++;
break;
}
else{
l++;
continue LOOP;
}
}
case 7:{
if(d[6]<=number[6]){
output[i]=eng_types[6];
d[6]++;
break;
}
else{
l++;
continue LOOP;
}
}
case 8:{
if(d[7]<=number[7]){
output[i]=eng_types[7];
d[7]++;
break;
}
else{
l++;
continue LOOP;
}
}
}
}
}
}
return output;
}
public static void main(String args[]) {
int i=0;
Scanner scan = new Scanner(System.in);
System.out.println("Uva Wellassa University of Sri Lanka");
System.out.println("Enter the the percentage of intake for each disciplines");
String c[]={"1.Biomedical_Engineering","2.Electrical_Engineering","3.Chemical_&_Process_Engineering",
"4.Electronic and Telecommunication Engineering","5.Civil Engineering","6.Mechanical Engineering",
"7.Computer Science & Engineering","8.Materials Science & Engineering"};
float[] percent = new float[8];
for(int p=0;p<8;p++){
System.out.printf(c[p]+":");
percent[p]=scan.nextFloat();
}
float validity_of_percentage=percentage(percent);
if(validity_of_percentage==100){
int y;
System.out.println("Uva Wellassa University of Sri Lanka");
System.out.print("Enter the number of students you\'re going to process:");
y=scan.nextInt();
int[] num = new int[8];
for(i=0;i<8;i++){//1 num=no of people we've gonna intake
num[i]= y*(int)percent[i]/100;
}//1
float gpa[] = new float[y];
float[] newgpa = new float[y];
int course[][]= new int[y][];
String en_num[] = new String[y];
for(int r=0;r<y;r++){//2
System.out.printf("\nEnter the enrolment number of the student %d:",r+1);
scan.nextLine();
en_num[r]=scan.nextLine();
System.out.printf("\nEnter the GPA of the student %d:",r+1);
gpa[r]=scan.nextFloat();
//check validity of gpa must be included here
System.out.printf("\nEnter the number of courses student %d likes to apply:",r+1);
int num1=scan.nextInt();
System.out.printf("\n");
for(int j=0;j<8;j++){//3
System.out.printf(c[j]+"\n");
}//3
course[r]= new int[num1];
for(int l=0;l<num1;l++){//4
System.out.printf("\nEnter the selection %d of student %d:",r+1,r+1);
course[r][l]=scan.nextInt();
}//4
}//2
newgpa=gpa;
Arrays.sort(gpa);
System.out.println(newgpa);
System.out.println(gpa);
String[] op=Process(newgpa,gpa,y,course,c,num);
Output(newgpa,op,y,en_num);
}
else
System.out.println("Input was incorrect");
}
}