help with java program
I'm getting errors while compiling this. Can someone point me in the right direction?
public class MaleFemaleGPA
static Scanner inFile = new Scanner(new FileReader(GPAdata.dat));
public static void main(String args)
char maleTotal, femaleTotal;
int maleCount, femaleCount;
double maleAverage, femaleAverage;
if (inFile.next.charAt(0) = m)
maleTotal += inFile.nextDouble();
femaleTotal += inFile.nextDouble();
maleAverage = maleTotal / maleCount;
femaleAverage = femaleTotal / femaleCount;
System.out.println("Average GPA for male students is " + maleAverage);
System.out.println("Average GPA for female students is " + femaleAverage);
can you explain what do you do with the code? and what is the problem exactly?
so I can test it and help you
I have a file that is in the format:
The program is supposed to get the average of all the m's and f's. The m is for Male the f is for Female. The number beside of each m or f is the GPA. So it needs to get the average GPA for all male students and all female students.
You have to define maleTotal, femaleTotal as real or double; maleCount, femaleCount as integer and then initialized them