public class Grades{
	
public int scoreTotal;
public int numScores;
double average;
static String file = "randomNumbers.txt"; 	
int lowest;
int x;
int temp;

public static void main(String[] args) throws FileNotFoundException{

int scoreTotal = 0;
int numScores = 0;
double average = 0;
int lowest = -1;
int temp = 0;

Scanner optScan = new Scanner(System.in);
System.out.println("Do you want to drop your lowest score? Enter true or false.");
boolean isDropped = optScan.nextBoolean(); 
    
Scanner scan = new Scanner(file);    

while(scan.hasNextInt()){
temp = scan.nextInt();
scoreTotal += temp;

   	 	if(lowest>temp) {
   	 		lowest = temp;
   	 		}
 

    if(isDropped==true){
   	average = (scoreTotal-lowest)/(numScores-1);
    }
    
    else if(isDropped==false){
   	average = (scoreTotal/numScores);
    }
}
System.out.println("This is the average: "+average);    
System.out.println("This is the score total: " +scoreTotal);
System.out.println("This is the lowest: " +lowest);

}
}

Currently, it is returning this if I type in true for the boolean isDropped:
This is the average: 0.0
This is the score total: 0
This is the lowest: -1


And if false:
This is the average: 0.0
This is the score total: 0
This is the lowest: -1

So it's not calculating anything, it's only taking the initial values. I'm pretty new to Java and have been tweaking this for a while...with no results. Help appreciated greatly, thanks! :)

For debugging your code I'd recommend you add printlns to show the values of variables as they change and to show the execution flow. The print out should help you understand what the problem is.

You forgot to show what the correct output should be.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.