public class CalcAverage
{
public static void main(String[] args)
{
int numScores; // To hold the number of scores
// Create a Scanner object for keyboard input.
Scanner keyboard = new Scanner(System.in);
// Get the number of test scores.
System.out.print("How many test scores do you have? ");
numScores = keyboard.nextInt();
// Create an array to hold the test scores.
double[] scores = new double[numScores];
// Get the test scores and store them
// in the scores array.
for (int index = 0; index < numScores; index++)
{
System.out.print("Enter score #" +
(index + 1) + ": ");
scores[index] = keyboard.nextDouble();
}
// Create a Grader object, passing the
// scores array as an argument to the
// constructor.
Grader myGrader = new Grader(scores);
// Display the adjusted average.
System.out.println("Your adjusted average is " +
myGrader.getAverage());
// Display the lowest score.
System.out.println("Your lowest test score was " +
myGrader.getLowestScore());
試試這個它我組的演示程序,它應該幫助您得到的如何,因爲它似乎那些誰真正知道該怎麼做不會費心幫得到你所需要的信息的想法。對不起,我不能完全回答你的問題。
你允許使用'ArrayList'嗎? – ajb
這是['ArrayList'](https://docs.oracle.com/javase/8/docs/api/index.html?java/util/ArrayList.html)的用途。 – Gendarme
謝謝你的幫助 –