-1
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.

Votes + Comments
Your user name precludes any desire to help you with a single thing. Fail.
2
Contributors
1
Reply
2
Views
4 Years
Discussion Span
Last Post by JamesCherrill
0

near line 51, where you keep track of the highest score, you can also update a String variable to store the name associated with that score. Then hyou can print that variable after the loop.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.