Skip to content
Open

Lab4 #10

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/GradeProcessor.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import java.util.Map;

public class GradeProcessor {
public static Map<String, Student> increaseGrades(Map<String, Student> studentsMap) {
for (Student student : studentsMap.values()) {
int newGrade = (int) (student.getGrade() * 1.1);

newGrade = Math.min(newGrade, 100);
student.setGrade(newGrade);
}
return studentsMap;
}
}
26 changes: 26 additions & 0 deletions src/Main.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import java.util.HashMap;
import java.util.Map;

public class Main {
public static void main(String[] args) {
Map<String, Student> studentsMap = new HashMap<>();


Student alice = new Student("Alice", 85);
Student bob = new Student("Bob", 90);
Student charlie = new Student("Charlie", 78);
Student diana = new Student("Diana", 92);


studentsMap.put(alice.getName(), alice);
studentsMap.put(bob.getName(), bob);
studentsMap.put(charlie.getName(), charlie);
studentsMap.put(diana.getName(), diana);

studentsMap = GradeProcessor.increaseGrades(studentsMap);

for (Student student : studentsMap.values()) {
System.out.println(student.getName() + ": " + student.getGrade());
}
}
}
25 changes: 25 additions & 0 deletions src/Student.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
public class Student {
private String name;
private int grade;

public Student(String name, int grade) {
this.name = name;
this.grade = grade;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getGrade() {
return grade;
}

public void setGrade(int grade) {
this.grade = grade;
}
}