The program I am working on takes numbers from a plain text file, and does calculations based on the numbers. One of the calculations needed is the overall minimum value.
The issue lies in the fact that my current minimum score variable is set to equal the current-selected value from the text document. So, it basically is always going to be equal to the last value. Or, alternatively it is always equal to zero if I do not set the two values to be equal to each other. The trouble is, I have no idea how to accurately calculate the minimum value.
Java Code
public class ExamStats {
static final int bottomA = 90;
static final int bottomB = 80;
static final int bottomC = 70;
static final int bottomD = 60;
public static void main(String[] args) throws FileNotFoundException {
double totalSum = 0;
int numberOfExams = 0;
double examAverage = 0;
int currentScore = 0;
double aCount = 0;
double bCount = 0;
double cCount = 0;
double dCount = 0;
double fCount = 0;
double aPercent = 0;
double bPercent = 0;
double cPercent = 0;
double dPercent = 0;
double fPercent = 0;
int maxScore = 0;
int minScore = 0;
Scanner scan = new Scanner(System.in);
File f = new File("Grades.txt");
DecimalFormat twoDecimal = new DecimalFormat("#.##");
DecimalFormat noDecimal = new DecimalFormat("#");
System.out.println("Enter the name of the file here: ");
String fileName = scan.nextLine();
Scanner fileLocation = new Scanner(new FileReader(fileName));
while (fileLocation.hasNext()){ //Reads each individual entry from the text file.
currentScore = fileLocation.nextInt();
numberOfExams++;
totalSum += currentScore;
if (currentScore >= bottomA){
aCount++;
}
if (currentScore >= bottomB && currentScore < bottomA){
bCount++;
}
if (currentScore >= bottomC && currentScore < bottomB){
cCount++;
}
if (currentScore >= bottomD && currentScore < bottomC){
dCount++;
}
if (currentScore < bottomD) {
fCount++;
}
if (currentScore < minScore){
minScore = currentScore;
}
if (currentScore > maxScore){
maxScore = currentScore;
}