Input file looks like this
BASKETBALL
John Smith
23 , 54
FOOTBALL
Jose Cruise
445, 23
BASKETBALL
KJ
34, 32
BASEBALL
Mike Beterman
3, 2
FOOTBALL
David Smith
323, 23
Below is my code.
What is happening on my output I get
Sport: BASKETBALL Name: John Smith Stat: 23 , 54
Sport: FOOTBALL Name: Jose Cruise Stat: 445, 23
Sport: BASEBALL Name: Mike Beterman Stat: 323, 23
I need all the names and all the stats to be printed out..
Sport: BASKETBALL Name: John Smith Stat: 23 , 54
Sport: FOOTBALL Name: Jose Cruise Stat: 445, 23
Sport: BASKETBALL Name: KJ Stat: 34, 32
Sport: BASEBALL Name: Mike Beterman Stat: 3, 2
Sport: FOOTBALL Name: David Smith Stat:323, 23
Can someone tell me what I am doing wrong in my code Please?
BufferedReader in = new BufferedReader(new FileReader(infile));
String line = "not empty";
while (line != null)
{
if (line.equals("BASKETBALL"))
{
String Name = in.readLine();
String stats= in.readLine();
AddBasketballPlayer("Basketball", Name, Stats);
line = in.readLine();
}
if(line.equals(""BASEBALL"))
{
String Name = in.readLine();
String stats= in.readLine();
AddBaseballPlayer("Baseball", Name, Stats);
line = in.readLine();
}
if(line.equals("FOOTBALL"))
{
String Name = in.readLine();
String stats= in.readLine();
AddFootballPlayer("Football", Name, Stats);
line = in.readLine();
}
}