Okay so I'm supposed to read in grades from a file add them together and get the average the letter grade the minimum grade and the maximum...no setting variables to the read in...and the sentinel is -1 at the end of the sequence...I'm a bet messed up...this is what i have so far

import java.io.*;
import java.util.*;

public class Grader

static final int SENTINEL = -1;

public static void main(String[] args) throws
Scanner inFile=
new Scanner(new FileReader("scores.dat"));
PrintWriter outFile = new

//declare variables
int num;
int score;
int max;
int min;
char grade;

//receives information from file
num = inFile.nextInt();

if (num != SENTINEL)
score = 0;
num = inFile.nextInt();
score = score+num;
} while (num != SENTINEL);

if (score > 100)
System.out.println("Invalid data value. Program exiting...");

if ((score/10) >= 90)
grade = 'A';
else if ((score/10) >= 80 && (score/10)< 90)
grade = 'B';
else if ((score/10) >= 70 && (score/10)< 80)
grade = 'C';
else if ((score/10) >= 60 && (score/10)< 70)
grade = 'D';
else if ((score/10) < 60 && (score/10) > 0)
grade = 'F';





For start, you declared SENTINEL to be a constant so it will never change

static final int SENTINEL = -1;

Secondly, if I interpreted your statement correctly you expect this variable have different value on the end. The value will not change even if you remove final from its declaration, SENTINEL stays as -1, because there are no changes to it in your program

This article has been dead for over six months. Start a new discussion instead.