import java.io.*;
import java.util.*;
public class Cleeve {
/**
* @param args
*/
public static void main(String[] args) throws IOException {
File inFile = new File("Sport.txt");
Scanner inFile2 = new Scanner(inFile);
File outFile = new File("Proffesional.txt");
PrintWriter outfile = new PrintWriter(outFile);
File outFile2 = new File("AmaturElse.txt");
PrintWriter outfile2 = new PrintWriter(outFile2);
String inData = null;
String name = null;
String category = null;
int gold = 0;
int silver = 0;
int bronze = 0;
int sum = 0;
int total = 0;
int total1 = 0;
int t_sum = 0;
int t_sum1 = 0;
int highest = 0;
int i;
while(inFile2.hasNext()){
inData = inFile2.nextLine();
StringTokenizer st = new StringTokenizer(inData,";");
name = st.nextToken();
category = st.nextToken();
gold = Integer.parseInt(st.nextToken());
silver = Integer.parseInt(st.nextToken());
bronze = Integer.parseInt(st.nextToken());
sum = gold + silver + bronze;
i = 0;
if(category.equals("Professional")){
total = total + 1;
sum = sum * 10;
t_sum = t_sum + sum;
outfile.println(name + "\t" + category + "\t" + gold + "\t" + silver + "\t" + bronze + "\t" + sum);}
else{
total1 = total1 + 1;
sum = sum * 5;
t_sum1 = t_sum1 + sum;
outfile2.println(name + "\t" + category + "\t" + gold + "\t" + silver + "\t" + bronze + "\t" + sum);}
while(st.nextToken() != null){
sum = Integer.parseInt(st.nextToken());
if(sum >= highest){
highest = sum;
i++;
}
}
}
System.out.print(highest);
outfile.println(total + "\t" + t_sum);
outfile2.println(total1 + "\t" + t_sum1);
inFile2.close();
outfile.close();
outfile2.close();
}
}
The problem with this codes is i can't output the name of the highest score. Everything else is working correctly except outputting the name. Please help me.