Write a program that reads a student's name together with their test scores?

Write a program that reads a student's name together with their test scores. the program should then compute the average test scores for each student and assign the appropriate grade.

Your program must use the following methods:
a. A value-returning method, calculateAverage, to determine and return the average of five test scores for each student. Use a loop to read and sum the five test scores.

b. A value-returning method, calculateGrade, to determine and return each student's grade .

Read in file:
Johnson 85 83 77 91 76
Aniston 80 90 95 93 48
Cooper 78 81 11 90 73
Gupta 92 83 30 69 87
Blair 23 45 96 38 59
Clark 60 85 45 39 67
Kennedy 77 31 52 74 83
Broson 93 94 89 77 97
Sunny 79 85 28 93 82
Smith 85 72 49 75 63

This what i have so far i am totally lost. Can anyone please help?

import java.util.*;
import java.io.*;
public class Chpt7_User_Defined_Methods
{
public static void main(String[] args)throws FileNotFoundException

{
String fileName = "studentFile.txt";
String studentTestScores1 = "";
String studentTestScores2 = "";
String studentTestScores3 = "";
String studentTestScores4 = "";
String studentTestScores5 = "";
String studentTestScores6 = "";
String studentTestScores7 = "";
String studentTestScores8 = "";
String studentTestScores9 = "";
String studentTestScores10 = "";
Scanner inFile = new Scanner (fileName);
double calculateAverage =0.0;
double calculateGrade = 0.0;
double gradeSum = 0.0;

for (int i = 1; i <11; i++)
{
if ( i == 1)
{
studentTestScores1 = inFile.next();
int Scores1 = inFile.nextInt();
System.out.println(studentTestScores1 + " account read in");
}
if ( i == 2)
{
studentTestScores2 = inFile.nextInt();
System.out.println(studentTestScores2 + " account read in");
}
if ( i == 3)
{
studentTestScores3 = inFile.nextInt();
System.out.println(studentTestScores3 + " account read in");
}
if ( i == 4)
{
studentTestScores4 = inFile.nextInt();
System.out.println(studentTestScores4 + " account read in");
}
if ( i == 5)
{
studentTestScores5 = inFile.nextInt();
System.out.println(studentTestScores5 + " account read in");
}
if ( i == 6)
{
studentTestScores6 = inFile.nextInt();
System.out.println(studentTestScores6 + " account read in");
}
if ( i == 7)
{
studentTestScores7 = inFile.nextInt();
System.out.println(studentTestScores7 + " account read in");
}
if ( i == 8)
{
studentTestScores8 = inFile.nextInt();
System.out.println(studentTestScores8 + " account read in");
}
if ( i == 9)
{
studentTestScores9 = inFile.nextInt();
System.out.println(studentTestScores9 + " account read in");
}
if ( i == 10)
{
studentTestScores10 = inFile.nextInt();
System.out.println(studentTestScores10 + " account read in");
}
}
}
}
 
Back
Top