style:fmt

This commit is contained in:
dichgrem
2025-11-15 13:30:17 +08:00
parent c20e8949a5
commit 41e6b71bd7
33 changed files with 549 additions and 543 deletions

View File

@@ -1,40 +1,46 @@
package com.study.demo2;
public class Student {
private String id;
private String name;
private int[] score = new int[10];
private String id;
private String name;
private int[] score = new int[10];
public Student(String id, String name, int[] scores) {
this.id = id;
this.name = name;
if (scores.length == 10) {
this.score = scores;
}
public Student(String id, String name, int[] scores) {
this.id = id;
this.name = name;
if (scores.length == 10) {
this.score = scores;
}
}
public double getAverage() {
int sum = 0;
for (int s : score) {
sum += s;
}
return (double) Math.round((sum / 10.0) * 100) / 100;
public double getAverage() {
int sum = 0;
for (int s : score) {
sum += s;
}
return (double) Math.round((sum / 10.0) * 100) / 100;
}
public int getMaxScore() {
int max = score[0];
for (int s : score) {
if (s > max) max = s;
}
return max;
public int getMaxScore() {
int max = score[0];
for (int s : score) {
if (s > max)
max = s;
}
return max;
}
public char getGrade() {
double avg = getAverage();
if (avg >= 90) return 'A';
else if (avg >= 80) return 'B';
else if (avg >= 70) return 'C';
else if (avg >= 60) return 'D';
else return 'E';
}
}
public char getGrade() {
double avg = getAverage();
if (avg >= 90)
return 'A';
else if (avg >= 80)
return 'B';
else if (avg >= 70)
return 'C';
else if (avg >= 60)
return 'D';
else
return 'E';
}
}