• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

text formatting using java

 
Ryan Speller
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
ok stuck on this one and looking for help

before i say a word heres what I have so far and what I need to do:



I think the comments sum up what I am doing, but I need help on the three TODO areas at the end.

Basically the end product should have you entering a text file and then formatting it according to maxWidth.


Started a new job this week 7am-6pm M-F so I am unbelievably exhausted and I just can't seem to figure out this last part and I know it should not be this hard.

Any help is appreciated, any help in the form of code is god-like.

Thanks
 
Campbell Ritchie
Sheriff
Pie
Posts: 49823
69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Go and find the "cattle drive" part of this website and find the example (I think 1a) which prints Gertrude 100 times. Several other people are struggling with a similar problem, or with the cattle drive example which prints Gertrude without going over the end of the line. Do a search of this forum for 1b; it was only a few days ago.

What you need is to count the length of your ************************** line, count the length of line you have got to print out already, and if there isn't enough space for the next word, go onto a new line.
Remember to allow for your spaces.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic