//import all necessary packages
import java.util.*;
import java.io.*;
class Main {
public static void main(String[] args)
{
try
{
//Allow for input.
File allStudentGrades = new File("data.txt");
File addAStudentFile = new File("newStudent.txt");
Scanner scannerForInfoCapturing = new Scanner(allStudentGrades);
Scanner scannerForAddMethod = new Scanner(addAStudentFile);
//Use a two-dimensional array to store student data.
int studentData[][] = new int[10][10];
String studentNames[] = new String[10];
//very bottom of main method.. run all of the custom methods
ListGrades(studentNames, studentData); //requires 2 variables
AddStudent(studentNames, studentData);
ClassAverage(studentNames, studentData);
StudentAverage(studentNames, studentData);
}
catch(FileNotFound e)
{
//output error to user
}
catch(NoSuchElement n)
{
//output error to user
}
}
public static void ListGrades(String [] nameList, int [][] gradeList)
{
info = scannerForInfoCapturing.nextLine(); //using a scanner for the data.txt file
//output names (stored inside the nameList[]) and grades (stored inside the gradesList[][])
//HINT: use a nested for loop
for(int i=0i<??i++) //repeat for each student (10 times max)
{
for() //repeat for each grade (4 times max)
{
}
}
}
public static void AddStudent()
{
info = scannerForAddMethod.nexTLine(); //using scanner for the newstudent.txt file
//HINT: use a nested for loop
for() //repeat for new student (1 time)
{
//store in the orignal studentNames[] array
for() //repeat for each grade (4 times max)
{
//store in the orignal studentData[][] array
}
}
//output the information of the new student
}
public static void ClassAverage()
{
info = scannerForInfoCapturing.nextLine(); //using a scanner for the data.txt file
//output names (stored inside the nameList[]) and grades (stored inside the gradesList[][])
//HINT: use a nested for loop
for() //repeat for each student (10 times max)
{
for() //repeat for each grade (4 times max)
{
//adding all grades
}
//adding student averages to a total class count
}
//take total class count divided by number of students in the class
}
public static void StudentAverage()
{
info = scannerForInfoCapturing.nextLine(); //using a scanner for the data.txt file
//output names (stored inside the nameList[]) and grades (stored inside the gradesList[][])
//HINT: use a nested for loop
for() //repeat for each student (10 times max)
{
for() //repeat for each grade (4 times max)
{
//adding all grades
}
}
//output grades/4
}
}
Troy
98
64
48
84
Tyler
98
76
48
97
Zak
91
73
78
93
Mohammad
99
77
48
88
Alex
87
58
79
69