Student Score Statistics
Submit solution
Points:
10 (partial)
Time limit:
1.0s
Memory limit:
64M
Authors:
Problem type
Allowed languages
Java 19, Java 8
題目說明
請設計一個類別來處理學生成績,並完成以下功能:
getHighest:找出最高分getLowest:找出最低分reverseSequence:將分數反過來輸出
輸入格式
- 第一行:整數
N,代表分數數量 - 第二行:
N個整數,代表學生分數
輸出格式
- 第一行輸出最高分
- 第二行輸出最低分
- 第三行輸出反轉後的分數
Java 部分程式碼
你只要把 TODO 的地方補完即可:
import java.util.Scanner;
class ScoreManager {
// 找最高分
public int getHighest(int[] arr) {
// TODO
}
// 找最低分
public int getLowest(int[] arr) {
// TODO
}
// 反轉輸出
public void reverseSequence(int[] arr) {
// TODO
}
}
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int[] scores = new int[n];
for (int i = 0; i < n; i++) {
scores[i] = sc.nextInt();
}
ScoreManager sm = new ScoreManager();
System.out.println(sm.getHighest(scores));
System.out.println(sm.getLowest(scores));
sm.reverseSequence(scores);
}
}
Sample Input
5
60 75 90 85 100
Sample Output
100
60
100 85 90 75 60
Comments