import java.util.Scanner;
public class Lab6
{
public static void main(String[] args)
{
// Fill in the body according to the following comments
Scanner in = new Scanner(System.in);
// Input file name
String filename = getFileName(in);
// Input number of students
int n = FileIOHelper.getNumberOfStudents(filename);
// Input all student records and create Student array and
// integer array for total scores
Student [] students;
students[n] getStudents(n);
int [] totalScores = new int [n];
int j = 0;
while (j < n)
{
totalScores[j] = (std.getScore(1) + std.getScore(2) + std.getScore(3));
j++;
}
// Compute total scores and find students with lowest and
// highest total score
// Compute average total score
// Output results
}
// Given a Scanner in, this method prompts the user to enter
// a file name, inputs it, and returns it.
private static String getFileName(Scanner in)
{
// Fill in the body
System.out.print("Enter input file name: ");
String filename = in.nextLine();
return filename;
// Do not declare the Scanner variable in this method.
// You must use the value this method receives in the
// argument (in).
}
// Given the number of students records n to input, this
// method creates an array of Student of the appropriate size,
// reads n student records using the FileIOHelper, and stores
// them in the array, and finally returns the Student array.
private static Student[] getStudents(int n)
{
// Fill in the body
int pos = 0;
Student[] students;
while (pos < n)
{
students[pos] = FileIOHelper.getNextStudent();
pos = ++pos;
}
return students;
}
// Given an array of Student records, an array with the total scores,
// the indices in the arrays of the students with the highest and
// lowest total scores, and the average total score for the class,
// this method outputs a table of all the students appropriately
// formatted, plus the total number of students, the average score
// of the class, and the name and total score of the students with
// the highest and lowest total score.
private static void outputResults(
Student[] students, int[] totalScores,
int maxIndex, int minIndex, int average
)
{
// Fill in the body
}
// Given a Student record, the total score for the student,
// and the average total score for all the students, this method
// outputs one line in the result table appropriately formatted.
private static void outputStudent(Student s, int total, int avg)
{
// Fill in the body
System.out.println(Student(filename) + std.getScore(1) + std.getScore(2) + std.getScore(3) + (std.getScore(1) + std.getScore(2) + std.getScore(3)));
}
// Given the number of students, this method outputs a message
// stating what the total number of students in the class is.
private static void outputNumberOfStudents(int n)
{
// Fill in the body
System.out.println("Number of students: " + n);
}
// Given the average total score of all students, this method
// outputs a message stating what the average total score of
// the class is.
private static void outputAverage(int average)
{
// Fill in the body
}
// Given the Student with highest total score and the student's
// total score, this method outputs a message stating the name
// of the student and the highest score.
private static void outputMaxStudent(
Student student,
int score
)
{
// Fill in the body
}
// Given the Student with lowest total score and the student's
// total score, this method outputs a message stating the name
// of the student and the lowest score.
private static void outputMinStudent(
Student student,
int score
)
{
// Fill in the body
}
}