Code is acting funny and I don't know the issue. My program is supposed to read a number of lines of text from a file, and then convert them into numbers that resemble the input a user would make on a Nokia 3310 model. I think I have written a competent code, but my issue is that my program skips the first line of text and converts the second line of text.
The very first line of the file is meant to indicate the number of lines that follow
Here is the link to my repl for anyone that wants to try their hands at it: https://repl.it/@LordSpice/Old-Phone?live=AEaR-7GUOXPuwg
I found a solution to my issue through some help from Archie, but I am leaving this up along with the code for anyone who would ever find it interesting to look at or use
You are calling file.nextLine() twice in the same iteration of the for loop, once on line 21 (when declaring toConvert) and once on line 114 (when declaring waste).
This means that the file only converts every second line of text because only every second line will be declared toConvert and the encoding will follow.
To solve, get rid of lines 112-116.
Please upvote if you found this helpful :)
@ArchieMaclean Right, what I am doing is I am making my program read a line first, convert that line and print the numbers, then get rid of excess white-space. I don't need to print either the waste or the converted text. I am just printing waste to see what was read as waste, I guess I should have clarified that with a comment.
To elaborate even further, the intended order of commands is this:
read int and define it as loop -> read nextLine() -> read all characters in that line using a loop -> printing numbers -> reading whitespace as a nextLine() to avoid issues -> repeating the loops as many times as necessary