Jak określić wartości maksymalne i minimalne odczytane z pliku tekstowego w Javie

Robię zadanie domowe dla klasy i szukam pomocnych wskazówek, a nie pełnych rozwiązań. Zasadniczo muszę napisać program Java, który odczytuje plik tekstowy i wyświetla wiersz informacji po wierszu, wymienia numer linii, a na końcu wypisuje maksymalną i minimalną wartość oraz lata odnoszące się do każdego z nich. Plik tekstowy zawiera rok i temperaturę dla tego roku. Tak więc zawiera coś w rodzaju „1900 50.9”. Nie mam zamiaru używać tablicy ani skanera, jest to część zadania. Udało mi się już uzyskać program do drukowania każdego roku i odpowiednią temperaturę po linii z liczbą linii. Powiedziano mi i użyłem pętli while. Teraz jedynymi problemami jest dostęp do pliku tekstowego w taki sposób, że mogę w jakiś sposób odróżnić się od wszystkich temperatur, które są maksymalne i które są minimalne, oraz w którym roku wystąpiło każde z nich. ponieważ chciałem być w stanie sam to rozgryźć, ale zadanie nie jest już warte żadnego kredytu z powodu późnych kar. Każda pomoc byłaby naprawdę doceniana, ponieważ nadal chcę to rozwiązać. Dzięki.

To jest to, co mam.

public class main {

/**
 * @param args the command line arguments
 */

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


File temps = new File ("temps.txt"); //Creates path to temps.txt file
FileReader textReader = new FileReader (temps); //Input information from temps.txt file into file reader
BufferedReader kb = new BufferedReader (textReader); //Use buffered reader to hold temps.txt file info from the file reader




String tempList; //Create string variable named tempList
int lineCount = 0; //Create integer variable named lineCount
String sep = ": Temp "; //Create string variable named sep (short for separation) and set it equal to the literal string ":"
String space = " "; //Create string variable named space and set it equal to an actual space between texts


System.out.println("The following is the provided information from the file input. ");
while ((tempList = kb.readLine()) !=null) { //while loop stating that as long as the text file still has values to read (is not null), continue to execute


    System.out.println("Line " + lineCount++ + ": Year " + tempList.replace(space, sep)); //Prints out the line number (lineCount++), the info from the temps.txt file with a ":" between the year and the number (tempList.replace (space,sep)

}




}

}

Dotychczasowym wynikiem jest:

Line 0: Year 1900: Temp 50.9
Line 1: Year 1901: Temp 49
Line 2: Year 1902: Temp 49.7
Line 3: Year 1903: Temp 49.5
Line 4: Year 1904: Temp 47.1
Line 5: Year 1905: Temp 49.1

Itd. Aż do ...

Line 99: Year 1999: Temp 52.7
BUILD SUCCESSFUL (total time: 0 seconds)

questionAnswers(3)

yourAnswerToTheQuestion