logo CodeStepByStep logo

justifyText

Language/Type: Java string parameters
Related Links:

Write a method named justifyText that accepts a string and a line width as an integer, and outputs to the console a multi-line string where each line is justified to the given width. A justified line contains as many words as will fit into the given width, with any whitespace distributed equally between the words. For example, ... ... The last line should be left-aligned and should not be justified.

Method: Write a Java method as described, not a complete program or class.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.