-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathClaudeAssignment.java
More file actions
230 lines (214 loc) · 6.61 KB
/
Copy pathClaudeAssignment.java
File metadata and controls
230 lines (214 loc) · 6.61 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
package com.creatio.crm.language.basics;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
public class ClaudeAssignment {
public static void main(String[] args) {
/**
* Build a program that: Data:
*
* Create 5 students using HashMap (name, subject1, subject2, subject3 scores)
*
* Logic:
*
* Calculate total score for each student Calculate average score for each
* student Use switch to assign grade:
*
* 90+ → "A" 75-89 → "B" 60-74 → "C" below 60 → "F"
*
*
* Print full report card for each student
*
* Collections:
*
* Store all students in ArrayList Store only students who passed (average > 60)
* in a separate ArrayList Store all unique grades given in a TreeSet
*/
// Student1
Map<String, String> student1 = new HashMap<String, String>();
student1.put("Name", "Somanjan Pramanik");
student1.put("Physics", "90");
student1.put("Chemistry", "92");
student1.put("Math", "97");
// Student2
Map<String, String> student2 = new HashMap<String, String>();
student2.put("Name", "Sp 369");
student2.put("Physics", "87");
student2.put("Chemistry", "89");
student2.put("Math", "95");
// student3
Map<String, String> student3 = new HashMap<String, String>();
student3.put("Name", "newlord 369");
student3.put("Physics", "70");
student3.put("Chemistry", "65");
student3.put("Math", "50");
// student4
Map<String, String> student4 = new HashMap<String, String>();
student4.put("Name", "newlord2.0 369");
student4.put("Physics", "79");
student4.put("Chemistry", "83");
student4.put("Math", "90");
// student5
Map<String, String> student5 = new HashMap<String, String>();
student5.put("Name", "Somanjan2.0 369");
student5.put("Physics", "93");
student5.put("Chemistry", "95");
student5.put("Math", "100");
// Grade
// Total Score
List<Map<String, String>> studentDataList = new LinkedList<Map<String, String>>();
studentDataList.add(student1);
studentDataList.add(student2);
studentDataList.add(student3);
studentDataList.add(student4);
studentDataList.add(student5);
System.out.println("***************************************************************");
for (int i = 0; i < studentDataList.size(); i++) {
float totalScore = 0;
for (String key : studentDataList.get(i).keySet()) {
if (key.equals("Name")) {
continue;
}
totalScore = totalScore + Float.parseFloat(studentDataList.get(i).get(key));
}
System.out.printf("%s's" + " total score out of 300: %f%n", studentDataList.get(i).get("Name"), totalScore);
totalScore = 0;
}
System.out.println("***************************************************************");
// Avg. Score
List<Float> avgScorelist = new LinkedList<Float>();
for (int i = 0; i < studentDataList.size(); i++) {
float AvgScore = 0;
for (String key : studentDataList.get(i).keySet()) {
if (key.equals("Name")) {
continue;
}
AvgScore = AvgScore + Float.parseFloat(studentDataList.get(i).get(key));
}
AvgScore = AvgScore / 3;
avgScorelist.add(AvgScore);
System.out.printf("%s's" + " Avg score: %f%n", studentDataList.get(i).get("Name"), AvgScore);
AvgScore = 0;
}
System.out.println("***************************************************************");
/**
* Use switch to assign grade:
*
* 90+ → "A" 80-89 → "B" 70-79 → "C" 60-69 → "D" below 60 → "F"
*/
System.out.println(avgScorelist);
for (int i = 0; i < avgScorelist.size(); i++) {
int grade = avgScorelist.get(i).intValue() / 10;
switch (grade) {
case 10:
System.out.println("Grade: A");
break;
case 9:
System.out.println("Grade: A");
break;
case 8:
System.out.println("Grade: B");
break;
case 7:
System.out.println("Grade: C");
break;
case 6:
System.out.println("Grade: D");
break;
default:
System.out.println("Grade: F");
}
}
System.out.println("***************************************************************");
/*
* Print full report card for each student
*
* List<Map<String, String>> studentDataList = new LinkedList<Map<String,
* String>>();
*/
System.out.println("All 5 students' report card is:");
for (int i = 0; i < studentDataList.size(); i++) {
float totalScore = 0;
for (String key : studentDataList.get(i).keySet()) {
if (key.equals("Name")) {
continue;
}
totalScore = totalScore + Float.parseFloat(studentDataList.get(i).get(key));
}
float avgScore = totalScore / 3;
System.out.printf("|Name: %s |" + "|Total score out of 300: %f ||Percentage: %f |",
studentDataList.get(i).get("Name"), totalScore, avgScore);
int grade = (int) avgScore / 10;
switch (grade) {
case 10:
System.out.println("Grade: A |");
break;
case 9:
System.out.println("Grade: A |");
break;
case 8:
System.out.println("Grade: B |");
break;
case 7:
System.out.println("Grade: C |");
break;
case 6:
System.out.println("Grade: D |");
break;
default:
System.out.println("Grade: F |");
}
totalScore = 0;
}
System.out.println("***************************************************************");
/*
* Store all students in ArrayList
* Store only students who passed (average > 85)
* in a separate ArrayList Store all unique grades given in a TreeSet
*/
System.out.println("All Students Data:"+studentDataList);
System.out.println("***************************************************************");
List<String> studentAbove85prcnt = new ArrayList<String>();
Set<String> uniqueGrade = new TreeSet<String>();
for (int i = 0; i < studentDataList.size(); i++) {
float totalScore = 0;
for (String key : studentDataList.get(i).keySet()) {
if (key.equals("Name")) {
continue;
}
totalScore = totalScore + Float.parseFloat(studentDataList.get(i).get(key));
}
float avgScore = totalScore / 3;
if (avgScore > 85.00) {
studentAbove85prcnt.add(studentDataList.get(i).get("Name"));
}
int grade = (int) avgScore / 10;
switch (grade) {
case 10:
uniqueGrade.add("A");
break;
case 9:
uniqueGrade.add("A");
break;
case 8:
uniqueGrade.add("B");
break;
case 7:
uniqueGrade.add("C");
break;
case 6:
uniqueGrade.add("D");
break;
default:
uniqueGrade.add("F");
}
}
System.out.println("Students Above 85 percentage:"+studentAbove85prcnt);
System.out.println("***************************************************************");
System.out.println("Unique Grades Student acuired:"+uniqueGrade);
}
}