• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

isolate words in strings, change characters

 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i am a complete idiot with programming. i have an assignment due tomorrow.
it has to take a simple user input, print out the length of the input, the length of the first and last words (causing me the most trouble). then switch some characters around several times and print each new text
 
Ranch Hand
Posts: 62
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nick,
shall we do your work? I would recommend a StringBuffer.
Regards
Torsten
 
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you read the user input into a String then you can use one of the methods of String to find the length.
You can use another method of String to find the first space (everything before it would be the first word) and the last space (everything after it would be the last word).
You can also achieve similar results by reading the user input into an array of chars and then using a for loop to find the spaces.
If you get some code together, post it here and maybe we can help you get through this.
 
Thomas Paul
mister krabs
Posts: 13974
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am moving this to "Java in General (beginners)".
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm doing about the same assignment as Nick Allen only I have to produce four files- ServerModel, ClientModel, ServerView and ClientView.
Here is my
can someone help me?!? thanks so much...
reply
    Bookmark Topic Watch Topic
  • New Topic