• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Cattle Drive- Assignment 4a

 
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Folks,

I'm having a bit of trouble with this exercise. The objective is to run the program with a number, e.g java Say 22 and then get an output of twenty- two (up to a max of 99).

Anyway, 1-9 is working fine for me, but that's it. I can't for the life of me see the problem, so any help would be appreciated! Thanks!




[* Sorry John, since this is a Cattle Drive assignment we need to keep the code out of the question. -Pauline]
 
Marshal
Posts: 70215
281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What did you pass as a command-line argument?
 
Campbell Ritchie
Marshal
Posts: 70215
281
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And, try passing some Strings to their substring method and see what you get from substring(2) especially when your input String is 2 characters long.
 
John Pisci
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks!

Just tried a very simple program (below) and can see where I was going wrong. How can you call the substring() method and only retrieve 1 character?


When the input was 'three', the output was:
b = hree
v = ree
 
John Pisci
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Fixed it- thanks for your help!

Just changed the following;

 
Don't get me started about those stupid light bulbs.
    Bookmark Topic Watch Topic
  • New Topic