Solution Review: Printing Styles
Have a look at the solution to the 'Printing Styles' challenge.
We'll cover the following...
Rubric criteria
Solution
Press + to interact
class Announcements{public static void men100meters(float time, String month, int year){System.out.println("Usain Bolt has broken the world record for men's 100 meters.");System.out.println( "" );System.out.print("Time taken:");System.out.println(time);System.out.print("Month:");System.out.println(month);System.out.print("Year:");System.out.println(year);}// testing codepublic static void main(String args[]){men100meters(9.58f, "August", 2009);}}
Rubric-wise explanation
Point 1:
The first line, i.e., Usain Bolt has broken the world record for men's 100 meters.
, is simply printed using println
because we need it to end with the line termination (see line 5). We need another empty line. Thus, we call println
with an empty text literal at line 6. Notice that having a " "
instead ...