Results 1 to 6 of 6

Thread: Reverse code

  1. #1
    ritch72 is offline Member
    Join Date
    Apr 2014
    Posts
    3
    Rep Power
    0

    Default Reverse code

    Just started a java class a week ago and already running into problems.

    Write an application, HiFour that prompt for four names and then prints the greetings, but with the names in reverse order and with punctuation as shown in the example.

    Enter four names: Alice Bob Carol Dave
    Hi Dave, Carol, Bob, Alice.

    Thanks!

  2. #2
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,440
    Blog Entries
    7
    Rep Power
    20

    Default Re: Reverse code

    Can you produce an array (or a List) that contains the names you supplied?

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    ritch72 is offline Member
    Join Date
    Apr 2014
    Posts
    3
    Rep Power
    0

    Default Re: Reverse code

    Quote Originally Posted by JosAH View Post
    Can you produce an array (or a List) that contains the names you supplied?

    kind regards,

    Jos
    They don't have to be the names that were supplied. The program is suppose prompt the user to enter four names, once the user does that, then the program will give the names in reverse order. Not sure how to make an array for user inputs. Thanks!

  4. #4
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,440
    Blog Entries
    7
    Rep Power
    20

    Default Re: Reverse code

    Quote Originally Posted by ritch72 View Post
    They don't have to be the names that were supplied. The program is suppose prompt the user to enter four names, once the user does that, then the program will give the names in reverse order. Not sure how to make an array for user inputs. Thanks!
    Ok, I'll rephrase my question: are you supposed to supply those four names on one single line? Of course those names can be different from the example.

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  5. #5
    ritch72 is offline Member
    Join Date
    Apr 2014
    Posts
    3
    Rep Power
    0

    Default Re: Reverse code

    Sorry, yes, one single line - and the single line should be a spaces between each name with no commas and the output needs to have commas after each name.

  6. #6
    JosAH's Avatar
    JosAH is online now Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,440
    Blog Entries
    7
    Rep Power
    20

    Default Re: Reverse code

    Quote Originally Posted by ritch72 View Post
    Sorry, yes, one single line - and the single line should be a spaces between each name with no commas and the output needs to have commas after each name.
    Ok, so that means that the names themselves can't have spaces in them; read the API documentation for the String.split( ... ) method; it'll do all the work for you (and it delivers an array of Strings which you have to print from the last to the first element).

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

Similar Threads

  1. Reverse Engineering of Uml diagrams from java code
    By shilpa80 in forum New To Java
    Replies: 2
    Last Post: 03-26-2014, 08:21 PM
  2. Replies: 1
    Last Post: 04-03-2013, 08:28 PM
  3. reverse engineer java code
    By gedas in forum New To Java
    Replies: 0
    Last Post: 04-09-2011, 03:06 PM
  4. Help with Reverse Guessing Game Code
    By koryvandell in forum New To Java
    Replies: 2
    Last Post: 04-04-2011, 01:53 AM
  5. Reverse engineer a java code
    By lenny in forum Advanced Java
    Replies: 1
    Last Post: 07-25-2007, 11:14 PM

Tags for this Thread

Posting Permissions

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