Results 1 to 7 of 7
  1. #1
    dany123456 is offline Member
    Join Date
    Nov 2009
    Posts
    1
    Rep Power
    0

    Default urgent:PLZ HELP I HAVE TEST TOMMOROW

    Hello all
    i see this exercise in the book
    Write a program to copy its input to its output, replacing each string of one or more blanks by a single blank
    example :
    input:I (more than one blank) love (more than one blank) Java.
    output:I(single blank) love(single blank) java.
    thankssssss

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Okay? And why are you telling us this? Just so you know, we are not going to do it for you.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Your posting the assignment without showing any work gives us concern as it suggests that you want someone else to do your work for you, which I'm sure is not true, which I'm sure is not your intent.

    Why don't you first show use your best attempt at solving this problem first, else we will have no idea where your current problems are and will have no idea how to help you.

    Much luck!
    Last edited by Fubarable; 11-09-2009 at 06:46 PM.

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Also, you may wish to tone down the "urgency" of your posts. It's your urgency, not ours, Also, we're all volunteers here, and no one likes to feel pressure, not even if we were being paid to help.

    Again, much luck.
    Last edited by Fubarable; 11-09-2009 at 06:48 PM.

  5. #5
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,449
    Blog Entries
    7
    Rep Power
    20

    Default

    Regular expressions were made for this; and I don't see what's so urgent about this all.

    kind regards,

    Jos

  6. #6
    Arnold is offline Member
    Join Date
    Oct 2009
    Location
    Rotterdam
    Posts
    52
    Rep Power
    0

    Default

    I assume you mean a space char by that.
    I'm not going to write the code, but try something like this:
    Have your input string being scanned per char. Once you encounter a space, check if the next char is a space too. If that's the case, then keep removing spaces...

  7. #7
    habester is offline Member
    Join Date
    Nov 2009
    Posts
    5
    Rep Power
    0

    Default

    Use a Scanner to get the text and then store it as a String. After that, use replaceAll(Text within string to replace, Replacement for text) to change all double spaces (" ") to single spaces (" "). You can also use trim to remove white space off the end. Good luck, use the java API to read about the methods!

Similar Threads

  1. *TEST* --ignore this--
    By angryboy in forum Reviews / Advertising
    Replies: 5
    Last Post: 05-01-2009, 08:15 AM
  2. Test - please delete
    By Fubarable in forum Forum Lobby
    Replies: 7
    Last Post: 04-25-2009, 08:08 PM
  3. Due Tommorow Writing a Program Please Help
    By gallimaufry in forum New To Java
    Replies: 4
    Last Post: 10-23-2008, 03:15 AM
  4. Junit test
    By alice in forum New To Java
    Replies: 1
    Last Post: 06-14-2008, 01:24 AM
  5. Replies: 0
    Last Post: 04-05-2008, 12:38 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
  •