• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cattle Drive- Assignment 4a

 
John Pisci
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]
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What did you pass as a command-line argument?
 
Campbell Ritchie
Sheriff
Pie
Posts: 49367
62
  • 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;

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic