Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMichael Smith
8,222 PointsTrying to get "Enter a letter:" to display on the line below "Try to solve:---------"
When I run my code in the console it appears like this: Try to solve: ---------Enter a letter:
rather than:
Try to solve:--------- Enter a letter:
How do I fix this?
Thanks!
3 Answers
Jeremiah Shore
31,168 PointsMichael Smith , you can have the "Enter a letter:" text appear on a new line by adding "%n" after "solve:---------". %n is more platform independent, \n applies to Mac and Linux, and \r\n works on Windows, but %n works universally.
For example:
System.out.print("solve:---------%n");
//could also use System.out.println();
String playerGuess = console.readLine("Enter a letter: ");
Keep in mind this example is not formatting the blank spaces in the solve string with the letters guessed correctly, but is hard-coded for a simple answer to your question.
Seth Kroger
56,413 PointsMake sure you print a "\n" for a new line after the "Try to solve: ----------".
Michael Smith
8,222 PointsAwesome got it guys. I missed that.