Page 2 of 2 FirstFirst 12
Results 21 to 24 of 24
  1. #21
    blacksky is offline Member
    Join Date
    Jan 2009
    Posts
    8
    Rep Power
    0

    Default

    EDIT: /* I have no clue how to print 10 chars at a time and then just go into the next line because it prints every single first line of all the chars that are entered. *_

    The problem is that a user can enter any kind of text, which I must then revert to the chars with symbols (*). Since every char is not the same length (some are 6, some 7 and some 8,...) I would have to sum up the length of every char until it reaches 80 or passes it and then do a line break. I would have to repeat that again if the chars reach 80th column again in the next line. The problem is I dont know how to do hat.

    I have tryed it with an if statement and to use "System.out.println()" but I didn't formulate it right. So it broke the chars in half after the 80th line. It then printed the second half of the chars it broke in the next line.
    Last edited by blacksky; 01-05-2009 at 11:39 PM.

  2. #22
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default ... at level 80 ...

    No, you can't have letters chopped in half... it's considered bad grammer :p. What is your worst case? Only 8 letter within the 80 column speed limit. Use that and just only print 8 letters per line (or how many letters you determined that can be safely printed). Might have to wrap another for/while loop around the two loops you already have to get the job done.

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

  3. #23
    blacksky is offline Member
    Join Date
    Jan 2009
    Posts
    8
    Rep Power
    0

    Default

    Yes I understand. The problem is I don't know how to count the chars since it prints every first line of all the chars (dot matrix printer style like you suggested). It's getting late so I'm having a hard time to concentrate :). I'll think about your suggestion and get back to you tomorrow.

    EDIT:

    In the worst case scenario I can print out 10 chars (the biggest char is 8 in length).

  4. #24
    Join Date
    Dec 2008
    Location
    Italy
    Posts
    79
    Rep Power
    0

    Default

    The problem is I don't know how to count the chars
    That's why, in a previous post, I suggested you to use an OO approach and create objects from class Symbol. That way you could now invoke a getLength() method to know the exact size of your char. Your way it's quite difficult to get the same thing, so you'll end up breaking line at the 10th character even if you could add more chars...

    Anyway, CJLSMan said you should wrap your code inside another for loop. That's the right way. But Java is an OO language and you should take advantage of this.

Page 2 of 2 FirstFirst 12

Similar Threads

  1. chars
    By whosadork in forum New To Java
    Replies: 6
    Last Post: 10-03-2008, 10:40 PM
  2. writting extended ascii chars on socket........or Endianness Issue......??
    By sachinj13 in forum Threads and Synchronization
    Replies: 8
    Last Post: 09-23-2008, 03:20 PM
  3. Can we append more than 255 chars to <a href>??
    By freddieMaize in forum Advanced Java
    Replies: 22
    Last Post: 07-18-2008, 05:04 PM
  4. Print the text file and print preview them
    By Java Tip in forum java.awt
    Replies: 0
    Last Post: 06-23-2008, 12:04 AM
  5. How to cut symbols from a string?
    By gutters in forum New To Java
    Replies: 3
    Last Post: 06-16-2008, 04:47 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •