String firstName = input.next();
String lastName = input.next();
String libraryNumber = input.next();
total += input.nextInt();
output.println(input.nextLine());//empty strings
You read the first name, "Alan", The second name "Alda", The library number "100", and the next int, which is 2. Then, you read right up until the next carriage return.. which is the very next character. Because \n
is stripped from the String
that is found, you're going to be getting an empty line. If I were you, I would read the whole line in, parse the String
itself and write it out.
Example
String line = input.nextLine();
String[] values = line.split(" ");
String firstName = values[0];
String secondName = values[1];
String libraryNumber = values[2];
total += Integer.parseInt(values[3]);
output.println(line);