Start New Discussion within our Software Development Community
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.out.println("Do you want to drop your lowest score? Enter true or false.");
boolean isDropped = optScan.nextBoolean(); 
Scanner scan = new Scanner(file);    

temp = scan.nextInt();
scoreTotal += temp;

   	 	if(lowest>temp) {
   	 		lowest = temp;

   	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.

This question has already been answered. Start a new discussion instead.