Write a function that returns a String with line breaks added so that it will not go over a given maximum width when printed.
For example, the call wordWrap(9,"one fish two fish red fish blue fish")
should return the String "one fish\ntwo fish\nred fish\nblue fish"
.
It is okay if your code doesn't handle Strings of long words with a short width. That is, you won't lose points if the call wordWrap(4,"abercrombie butterbeer charleston")
blows up or returns something weird.
one fish two fish red fish blue fish You are in a plush bedroom, with expensive-looking hardwood furniture. The bed is unmade. In the back of the room, the closet door is ajar. Would you like to open the door? ("yes" or "no") AAAAAA BBBBBBBB CCC CCCC DDDDDDDDD EE EE EE FF GGGGGGGGGG Always crushing you with knowledge to be in an earthquake
©2003–2016 Graham Mitchell
This assignment is licensed under a
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 United States License.