Win a copy of Head First Android this week in the Android forum!
  • 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Need help interpreting this script

 
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is a 2 part script taken from Head First Java:



And the output:


helloooo...
helloooo...
helloooo...
helloooo...
10


Now I went through and tried to "run" this program myself and here is how I did it:

(I hope this shows up ok).
Clearly I am wrong in adding these values up. I realize this may be a difficult question to answer online, but could someone point to where I went wrong? Thanks in advance


Edit by mw: Added code tags to formatted "table."
[ July 16, 2007: Message edited by: marc weber ]
 
Jake Miller
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Wow, that table did not show up at all how I wanted it to. Those are supposed to be columns with the headers: "x" "e1.count" "e2.count" and the values underneath. The key value (I think) is the 11 I got vs the 10 the program outputs.
 
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Jake Miller:
Wow, that table did not show up at all how I wanted it to. Those are supposed to be columns...


To preserve formatting with spaces like this, you can put the text inside code tags. I edited the original post for you.
 
marc weber
Sheriff
Posts: 11343
Mac Safari Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
See this post and try running the modified version of the code I posted there. Let us know if this helps.
 
Jake Miller
Ranch Hand
Posts: 43
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Haha, awesome, thanks a lot. I was doing exactly the same thing as Raymond in that post. Thanks again!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic