infinite loop:
while (inputStream.hasNext());
{
line = inputStream.nextLine();
firstWeight = inputStream.nextDouble();
while (inputStream.hasNextInt())
{
sum += inputStream.nextInt();
count ++;
avg = (sum/count);
}
lastWeight = inputStream.nextDouble();
outputStream.println(line + " " + firstWeight + " " + sum + " " + count + " " + lastWeight + " " + avg + " " + (lastWeight-firstWeight));
}
";" after "while (inputStream.hasNext())" is a empty expression, so java simply execute ";" while inputStream.hasNext() and don't consume the file
Next Problem, InputMissmatchException: you need this line for scanner:
inputStream =
new Scanner(new File("C:\\Test\\readTest.txt"));
inputStream.useLocale(Locale.ENGLISH);//this will help to interpret "." as decimal character
and final problem, you need this 2 lines at the end of while to consume the "newline" character:
lastWeight = inputStream.nextDouble();
outputStream.println(line + " " + firstWeight + " " + sum + " " + count + " " + lastWeight + " " + avg + " " + (lastWeight-firstWeight));
if(inputStream.hasNext())
inputStream.next(); // or even inputStream.nextLine();
now i get for the first person: Joe Schmoe 76.5 85 4 75.9 21.0 -0.5999999999999943 is it the right result?