I posted a topic on here a few weeks ago about a program I made that takes an input file (which is supposed to be a bowling score):
John Doe X9/XXXXX9/XXX9
and outputs this:
John Doe
Bowling Scores
_______________________________________________________________________
Bowler | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
-------------------+----+----+----+----+----+----+----+----+----+-----|
John Doe | X | 9/| X | X | X | X | X | 9/| X | XX9|
| | | | | | | | | | |
| 20| 40| 70| 100| 130| 159| 179| 199| 229| 258|
-------------------+----+----+----+----+----+----+----+----+----+-----|
Now I need to alter this code to take other bowlers from the input and output it below in the same format. So for:
2
John Doe1 X9/XXXXX9/XXX9
John Doe2 63-8F/--XX-/X9-8/X
Output would be:
John Doe
Bowling Scores
_______________________________________________________________________
Bowler | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
-------------------+----+----+----+----+----+----+----+----+----+-----|
John Doe1 | X | 9/| X | X | X | X | X | 9/| X | XX9|
| | | | | | | | | | |
| 20| 40| 70| 100| 130| 159| 179| 199| 229| 258|
-------------------+----+----+----+----+----+----+----+----+----+-----|
John Doe2 | 63| -8| F/| --| X | X | -/| X | 9-| 8/X|
| | | | | | | | | | |
| 20| 40| 70| 100| 130| 159| 179| 199| 229| 258|
-------------------+----+----+----+----+----+----+----+----+----+-----|
As you can see, the scores for the second bowler aren't correct. I basically tried looping the whole program and it mostly works but somewhere in that loop there I close the input file and reopen it in order to calculate the scores again. So I'm having trouble creating an "if" statement that needs to say on each loop iteration to ignore so many lines of input so that the correct score will be calculated for the corresponding bowling marks. Sorry if this is confusing... I can explain more or post some code if needed. Thanks for the help.
If this is all from a single input file, why would you need to re-open it? Couldn't you just keep reading? Other than that, make sure to reset your temporary "total score" variable to 0 each loop.
The first time through I need to read in the marks in order to output them and then I need to close and reopen it to read them in again to calculate the scores based on them. This worked fine in the original program and I don't want to alter it unless I absolutely have to. Yes I know to set the total score back to 0, I just didn't do it yet when I posted that output, sorry... but it won't do any good because now it's calculating the score based off the John Doe1 marks... if you notice, the gap between the highest and lowest John Doe2 score is the same as John Doe1's. Which means it's calculating John Doe2's score based off of John Doe1s marks. I need to find a way (on the second iteration of the loop) to skip some lines of data in the input file so it reads in the correct marks. Once again, I'm sorry if this is confusing...
I'm so lost now... I've been fooling with this forever and I can't get John Doe2's scores to output the right way. Should I be doing this in a loop or some other way? After wards, I also need to output the totals for each frame so I'm not sure where I'm even going with this right now. Thanks.