Hi
I'm working on creating a program for a grade processor. The end result is to determine the highest scaled and unscaled scores, I have included a copy of the sample data file that i'm using for input. I do not want to hard code the data file other than the scale factors which are defined in the code. And the output will display the name and two scores, which I have coded. Im having some issues with the logic in the main to calculate the final output.
Any input on direction would be a great help.
Sample Data File
Name Part 1 Part 2 Part 3 Part 4 Total Test Score
=============== ======== ======== ======== ======== ======== ======== ========
John Doe 12.20 8.50 3.14 2.30 26.14 1 31.63
Jane Jones 3.80 7.50 6.30 8.40 26.00 2 20.80
Jill Jensen 5.60 8.90 3.20 1.50 19.20 3 21.12
Paul Peterson 9.00 1 1.20 8.50 9.30 38.00 1 45.98
The contents of the first five columns are the name of the student and the corresponding score they received in each of the four parts of the test. The next column is the total of the points received by the student in the four parts. It is followed by a column indicating the version of the test taken by the student. The final column is the adjusted score computed based on the version of the exam taken by the student(multiplied the total score with the scale factor for the corresponding exam adjustment factor)
Exam Version Scale Factor
============ ============
1 1.21
2 0.80
3 1.10
ANY EXAM VERSION OTHER THAN 1,2 OR 3 IS NOT TO BE SCALED (OR SCALE IS 1.0)
--------My code so far--------------------------
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.text.DecimalFormat;
import java.util.Scanner;
import javax.swing.JOptionPane;
public class GradeProcessorTwo
{
public static void main(String []args) throws IOException
{
DecimalFormat gradeFormat = new DecimalFormat("#,#0");
final String SENTINEL = "END";
// Set the constants which will be used to determine adjust grades
final float ScaleFactor_1 = 1.21F;
final float ScaleFactor_2 = 0.80F;
final float ScaleFactor_3 = 1.10F;
double scaledScore = 0;
double total = 0;
int currentMaxRawScore = 0; // The current high score
String maxScoreReport = "";
// Get the location of the input file and open
String inputFileName;
inputFileName = JOptionPane.showInputDialog("Enter the name of the file containing grade data");
File inputFile = new File(inputFileName);
Scanner input = new Scanner (inputFile);
// Print the header to the console
System.out.printf("%-15s %8s %8s %8s %8s %8s %8s %8s\n", "Name", "Part 1", "Part 2", "Part 3", "Part 4", "Total", "Test #", "Score");
System.out.printf("%-15s %8s %8s %8s %8s %8s %8s %8s\n", "===============", "========", "========", "========", "========", "========","========","========");
while(input.hasNext())//read next data
{
String name = input.nextLine(); //read the name
int version = input.nextInt(); //read the test number
if( name.equals(SENTINEL))
break;
{
String test = input.nextLine();
int score = input.nextInt();
String maxScore;
if (score > currentMaxRawScore) //currentMaxScore = score;
{
currentMaxRawScore = score; //highest unadjusted score
float Score; // determine high scaled score from data file
if (version ==1)
scaledScore= currentMaxRawScore * ScaleFactor_1;
else if (version ==2)
scaledScore= currentMaxRawScore * ScaleFactor_2;
else if (version ==3)
scaledScore= currentMaxRawScore * ScaleFactor_3;
input.nextLine();
}
fileOut.flush();
fileOut.close();
input.close();
JOptionPane.showMessageDialog(null, maxScoreReport = (name + " has highest raw score of "+ currentMaxRawScore+"and adjusted score of"+scaledScore);
}
}
}
}