Tokenizing? It compiles, but I'm worried about "min" & "max"

The assignment is to:

Write a static method named numberStatistics that accepts a string of text as a parameter. Assume that the text is read from a file, "score.txt." The text is a series of strings (name) and integers (score). The method should process this text (maybe multiple lines) and report various statistics about the integers. Report the total number of the numbers, the sum of the numbers, the average of the numbers and the minimum and maximum numbers.

This is what I put together after the professor gave us a head start.

Code:

`import java.io.*; // for File `

import java.util.*; // for Scanner

public class TEST {

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

Scanner lineScan = new Scanner(new File("score.txt"));

int numNums = 0;

int sum = 0;

int max = 0;

int min = 0;

while (lineScan.hasNextInt()) {

int number = lineScan.nextInt();

numNums++;

sum += number;

if (number % 2 == 0) {

}

}

System.out.println("Total numbers = " + numNums);

System.out.println("Sum of numbers = " + sum);

System.out.println("Average = " + (sum/numNums));

System.out.println("maximum = " + max);

System.out.println("minimum = " + min);

}

}

It compiles, but I feel like I'm supposed to do something else for "max" & "min." I remember learning something about Math.min & Math.max. It compiling is enough for ME because I've been getting frustrated, but I do need to make sure...

Re: Tokenizing? It compiles, but I'm worried about "min" & "max"

Normally the min number would be the smallest number and max the largest. To find which number is the min or max number requires comparing all the numbers as they are read using an if statement.

One technique for doing the search is to initialize the min variable with the largest possible number before comparing it and the max variable with the smallest possible number. Then when the first compare is made the number will be smaller than the largest and larger than the smallest.

Another technique is to use the first number that is read in as the initial value for the min and max variables. Then as compares are made the correct choice is made.

BTW The statements should be indented to show nesting logic. Too many statements start in the first column.