Hey,
What I need to do is read a file- it will have a name and several numbers after, with -1 as a sentinel number to signal the end of line, ex:
Rogers 15 22 6 12 -1
Myers 23 10 4 22 34 -1
...
....
.....
What I want to do is display the original data, which I know how to do, take the numbers, except -1, read them, and display an average of each name's numbers, alone with the name with the highest number.
So far I can read the file and display it, but I'm not sure how to gather the numbers inside of the file and use them for displaying averages and maximum.
This is practice for a Java class, I know this will be on the next exam and I just can't figure it out. We aren't allowed to use arrays or any such, just iterations and filereader.
Thank you guys in advance for your help!
import java.io.*;
import java.util.Scanner;
public class HW7
{
public static void main (String[] args) throws IOException {
Scanner keyboard = new Scanner(System.in);
System.out.println("What is the name of the file?");
String fileName = keyboard.nextLine();
File file = new File(fileName);
Scanner inputFile = new Scanner(file);
while (inputFile.hasNext())
{
String line = inputFile.nextLine();
System.out.println(line);
}
}
}
So far, the code will read the file, and display it. That's as far as I can get, it's super frustrating not being able to do this.