📄 divingcompetition.java
字号:
import java.io.*;
import javagently.*;
class DivingCompetition {
/* The Diving program by J M Bishop Dec 1996
* ------------------ Java 1.1 October 1997
* updated May 2000
* Uses the Judge class to record the
* correct scores for dives.
* Illustrates calling class methods,
* and typed methods and using arrays
* in a separate class. */
Display d = new Display ("Dving Competition");
int noOfDives = 3;
int noOfJudges = 8;
DivingCompetition () throws IOException {
headings ();
double result, total = 0;
// There is one Dives object which records 8 scored
// and is reused for each dive
Dive dive = new Dive (noOfJudges);
int score;
for (int i=0; i < noOfDives; i++) {
d.println("Dive no: "+(i+1));
d.println("Enter the scores for the judges");
d.ready("Press ready to continue");
for (int j = 0; j < noOfJudges; j++) {
score = d.getInt("Judge "+(j+1));
dive.setScore(j, score);
}
dive.assessScores();
result = (double) (dive.sum
- dive.minScore - dive.maxScore)
/ (double) (noOfJudges - 2);
total += result;
d.println("Scores " + dive.minScore + " from judge "
+ dive.minJudge + " and " + dive.maxScore +
" from judge "
+ dive.maxJudge + " excluded.");
d.println("Result is: " + Text.writeDouble(result,5,1));
}
System.out.println("Diving average is : "+
Text.writeDouble(total/noOfDives,5,3));
}
void headings () {
d.println ("Diving Score Calculator\n" +
"=======================\n");
d.println("For each of " + noOfDives +
" dives give scores for "+noOfJudges+" judges.");
for (int i = 1; i<=noOfJudges; i++)
d.prompt ("Judge "+i,0);
}
public static void main (String [] args) throws IOException {
new DivingCompetition ();
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -