Reputation: 11
i'm struggling with a Java class that i'm trying to implement. Have a look at the class below. Excuse any poor coding you spot, i've just started learning java.
public void processFiles()
{
output.print(name + " " + id + " ");
while(input.hasNext())
{
String firstName = input.next();
String lastName = input.next();
String accNumber = input.next();
int nextInt = input.nextInt();
output.print(firstName);
output.print(lastName);
output.print(accNumber);
output.print(nextInt);
total = total + nextInt;
count = count + 1;
}
output.print("There are " + count + " accounts which together hold" + total + " points.");
closeLinks();
}
}
When I open the file i've created the text is all on one line and I can't work out how to start a new line. I've tried inserting '\n' into the code without success. Can someone please help.
Upvotes: 0
Views: 95
Reputation: 5715
Replace all
output.print();
with
output.println();
This would result in printing each on a separate line
Upvotes: 1