-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarks.java
More file actions
324 lines (296 loc) · 8.19 KB
/
Copy pathMarks.java
File metadata and controls
324 lines (296 loc) · 8.19 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
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
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
import javax.swing.*;
import java.awt.event.*;
public class Marks implements ActionListener{
JTextField mathsSctf;
JTextField englishSctf;
JTextField scienceSctf;
JTextField hindiSctf;
JTextField socialSctf;
JTextField itScSctf;
JTextField totalSctf;
JTextField mathsTotaltf;
JTextField englishTotaltf;
JTextField scienceTotaltf;
JTextField hindiTotaltf;
JTextField socialTotaltf;
JTextField itSctf;
JTextField itTotaltf;
JTextField totaltf;
JTextField mathsPertf;
JTextField englishPertf;
JTextField sciencePertf;
JTextField hindiPertf;
JTextField socialPertf;
JTextField itPertf;
JTextField totalPertf;
JTextField displaytf;
JTextField compartmentaltf;
JLabel subject;
JLabel marksSc;
JLabel marksTotal;
JLabel percentage;
JLabel maths;
JLabel english;
JLabel science;
JLabel hindi;
JLabel social;
JLabel it;
JLabel totallabel;
JLabel result;
JLabel note;
JButton calculate;
Marks(){
JFrame f = new JFrame("Grader");
subject = new JLabel("Subject");
subject.setBounds(30,50,80,20);
marksSc = new JLabel("Marks Scored");
marksSc.setBounds(110,50,100,20);
marksTotal = new JLabel("Total Marks");
marksTotal.setBounds(210,50,100,20);
percentage = new JLabel("Percentage");
percentage.setBounds(310,50,100,20);
maths = new JLabel("Maths");
maths.setBounds(30,80,80,20);
mathsSctf = new JTextField();
mathsSctf.setBounds(110,80,70,20);
mathsTotaltf = new JTextField();
mathsTotaltf.setBounds(210,80,70,20);
mathsPertf = new JTextField();
mathsPertf.setBounds(310,80,70,20);
mathsPertf.setEditable(false);
english = new JLabel("English");
english.setBounds(30,110,80,20);
englishSctf = new JTextField();
englishSctf.setBounds(110,110,70,20);
englishTotaltf=new JTextField();
englishTotaltf.setBounds(210,110,70,20);
englishPertf = new JTextField();
englishPertf.setBounds(310,110,70,20);
englishPertf.setEditable(false);
science = new JLabel("Science");
science.setBounds(30,140,80,20);
scienceSctf= new JTextField();
scienceSctf.setBounds(110,140,70,20);
scienceTotaltf = new JTextField();
scienceTotaltf.setBounds(210,140,70,20);
sciencePertf = new JTextField();
sciencePertf.setBounds(310,140,70,20);
sciencePertf.setEditable(false);
hindi = new JLabel("Hindi");
hindi.setBounds(30,170,80,20);
hindiSctf = new JTextField();
hindiSctf.setBounds(110,170,70,20);
hindiTotaltf=new JTextField();
hindiTotaltf.setBounds(210,170,70,20);
hindiPertf=new JTextField();
hindiPertf.setBounds(310,170,70,20);
hindiPertf.setEditable(false);
social = new JLabel("Social");
social.setBounds(30,200,80,20);
socialSctf=new JTextField();
socialSctf.setBounds(110,200,70,20);
socialTotaltf=new JTextField();
socialTotaltf.setBounds(210,200,70,20);
socialPertf=new JTextField();
socialPertf.setBounds(310,200,70,20);
socialPertf.setEditable(false);
it = new JLabel("I.T.");
it.setBounds(30,230,80,20);
itSctf= new JTextField();
itSctf.setBounds(110,230,70,20);
itTotaltf=new JTextField();
itTotaltf.setBounds(210,230,70,20);
itPertf = new JTextField();
itPertf.setBounds(310,230,70,20);
itPertf.setEditable(false);
totallabel = new JLabel("Total");
totallabel.setBounds(30,260,80,20);
totalSctf = new JTextField();
totalSctf.setBounds(110,260,70,20);
totalSctf.setEditable(false);
totaltf=new JTextField();
totaltf.setBounds(210,260,70,20);
totaltf.setEditable(false);
totalPertf = new JTextField();
totalPertf.setBounds(310,260,70,20);
totalPertf.setEditable(false);
totalPertf.setEditable(false);
result = new JLabel("Result");
result.setBounds(30,300,80,20);
displaytf = new JTextField();
displaytf.setBounds(140,300,80,20);
displaytf.setEditable(false);
note = new JLabel("Mandtory subjects: Maths & Science");
note.setBounds(30,350,300,20);
compartmentaltf = new JTextField();
compartmentaltf.setBounds(300,350,100,20);
compartmentaltf.setEditable(false);
calculate = new JButton("Calculate");
calculate.setBounds(180,400,100,20);
calculate.addActionListener(this);
f.add(subject);
f.add(marksSc);
f.add(marksTotal);
f.add(percentage);
f.add(maths);
f.add(mathsSctf);
f.add(mathsTotaltf);
f.add(mathsPertf);
f.add(english);
f.add(englishSctf);
f.add(englishTotaltf);
f.add(englishPertf);
f.add(science);
f.add(scienceSctf);
f.add(scienceTotaltf);
f.add(sciencePertf);
f.add(hindi);
f.add(hindiSctf);
f.add(hindiTotaltf);
f.add(hindiPertf);
f.add(social);
f.add(socialSctf);
f.add(socialTotaltf);
f.add(socialPertf);
f.add(it);
f.add(itSctf);
f.add(itTotaltf);
f.add(itPertf);
f.add(compartmentaltf);
f.add(totallabel);
f.add(totaltf);
f.add(totalSctf);
f.add(totalPertf);
f.add(result);
f.add(displaytf);
f.add(note);
f.add(calculate);
f.setSize(500,500);
f.setLayout(null);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String take1 = mathsSctf.getText();
String take2 = mathsTotaltf.getText();
String take3 = englishSctf.getText();
String take4 = englishTotaltf.getText();
String take5 = scienceSctf.getText();
String take6 = scienceTotaltf.getText();
String take7 = hindiSctf.getText();
String take8 = hindiTotaltf.getText();
String take9 = socialSctf.getText();
String take10 = socialTotaltf.getText();
String take11 = itSctf.getText();
String take12 = itTotaltf.getText();
double mathsSc=Integer.parseInt(take1);
double englishSc=Integer.parseInt(take3);
double scienceSc=Integer.parseInt(take5);
double hindiSc=Integer.parseInt(take7);
double socialSc=Integer.parseInt(take9);
double itSc=Integer.parseInt(take11);
double totalSc=0;
double mathsTotal=Integer.parseInt(take2);
double englishTotal=Integer.parseInt(take4);
double scienceTotal=Integer.parseInt(take6);
double hindiTotal=Integer.parseInt(take8);
double socialTotal=Integer.parseInt(take10);
double itTotal=Integer.parseInt(take12);
double total=0;
double mathsPer=0;
double englishPer=0;
double sciencePer=0;
double hindiPer=0;
double socialPer=0;
double itPer=0;
double totalPer=0;
mathsPer = (mathsSc/mathsTotal)*100;
englishPer=(englishSc/englishTotal)*100;
sciencePer=(scienceSc/scienceTotal)*100;
hindiPer=(hindiSc/hindiTotal)*100;
socialPer=(socialSc/socialTotal)*100;
itPer=(itSc/itTotal)*100;
totalSc=(mathsSc+englishSc+scienceSc+hindiSc+socialSc+itSc);
total=(mathsTotal+englishTotal+scienceTotal+hindiTotal+socialTotal+itTotal);
totalPer=(totalSc/total)*100;
String mathsPER = String.format("%.2f",mathsPer);
mathsPertf.setText(mathsPER);
String englishPER = String.format("%.2f",englishPer);
englishPertf.setText(englishPER);
String sciencePER = String.format("%.2f",sciencePer);
sciencePertf.setText(sciencePER);
String hindiPER =String.format("%.2f",hindiPer);
hindiPertf.setText(hindiPER);
String socialPER = String.format("%.2f",socialPer);
socialPertf.setText(socialPER);
String itPER =String.format("%.2f",itPer);
itPertf.setText(itPER);
String totalPER = String.format("%.2f",totalPer);
totalPertf.setText(totalPER);
String totalSC = String.format("%.2f",totalSc);
totalSctf.setText(totalSC);
String totaL = String.format("%.2f",total);
totaltf.setText(totaL);
String input="";
if(totalPer<=30) {
input = "FAIL";
}
else if ((totalPer>30)&&(totalPer<=60)) {
input = "C grade";
}
else if ((totalPer>60)&&(totalPer<=80)) {
input = "B grade";
}
else if (totalPer>80) {
input = "A grade";
}
displaytf.setText(input);
String back="";
if(mathsPer<=30) {
back="Compartmental";
}
else if(sciencePer<=30) {
back = "Compartmental";
}
else if(mathsPer>30) {
back = "null";
}
else if (sciencePer>30) {
back = "null";
}
compartmentaltf.setText(back);
String error="";
if(mathsTotal<mathsSc) {
error = "ERROR";
mathsPertf.setText(error);
displaytf.setText(error);
}
else if(englishTotal<englishSc) {
error = "ERROR";
englishPertf.setText(error);
displaytf.setText(error);
}
else if(scienceTotal<scienceSc) {
error = "ERROR";
sciencePertf.setText(error);
displaytf.setText(error);
}
else if(hindiTotal<hindiSc) {
error = "ERROR";
hindiPertf.setText(error);
displaytf.setText(error);
}
else if(socialTotal<socialSc) {
error = "ERROR";
socialPertf.setText(error);
displaytf.setText(error);
}
else if(itTotal<itSc) {
error = "ERROR";
itPertf.setText(error);
displaytf.setText(error);
}
}
public static void main (String args[]) {
new Marks();
}
}