Hi, I am a newbie programmer and I have an assignment due tomorrow that I haven't been able to figure out.
We are given a .txt file that contains NBA players names followed by some numbers that represent stats on the same line.
The program is simple. Ask the user for a player name (using JOptionPane) and the program spews out that players stats, the stats of the top player in the league and the average stats. The stats are calculated into an arbitrary made up "total stat" which I can easily calculate once I have all the individual ints.
The .txt file is in the following format:
NBA Player Name int1 int2 int3 int4 int5 int6 int7
NBA Player Name int1 int2 int3 int4 int5 int6 int7
NBA Player Name int1 int2 int3 int4 int5 int6 int7
NBA Player Name int1 int2 int3 int4 int5 int6 int7
NBA Player Name int1 int2 int3 int4 int5 int6 int7
etc.
The .txt file is read in using Scanner and we have not learned how to use arrays so I can't use those. We are supposed to be able to do this with String methods and using scanner and for/while loops.
I have something like this
I am panicking because I have no idea what I'm doing and my teacher hasn't responded to my email and I don't know anyone personally in my class. How do I separate the ints and names of each individual player? How can I take what the user inputs and have the program find that name and its associated stats and pull out JUST that player and his stats? I'm entirely lost.import java.io.*; import javax.swing.JOptionPane; import java.util.Scanner; public class GortemakerPeterA2Q3 { public static void main(String[] args) throws FileNotFoundException { Scanner inputFile = new Scanner(new File("nba-stats.txt")); Scanner readFile = new Scanner(System.in); Scanner lineScan; String playerName = JOptionPane.showInputDialog("Which NBA players P1010 score would you like to see?"); final int P_1010 = 2; String playerName2, line, stats; int length; String name = ""; } while(!inputFile.hasNextInt()){ name += " " + inputFile.next(); statsStart = name.length(); stats