This week's giveaway is in the Testing forum.
We're giving away four copies of TDD for a Shopping Website LiveProject and have Steven Solomon on-line!
See this thread for details.
Win a copy of TDD for a Shopping Website LiveProject this week in the Testing forum!
    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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

StringTokenizer, substring, for loop, while loop, filereader, filewriter

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
hello,

i have some text in notepad that looks like this



i am ask to create a program to call the notepad and make the output looks like this

       Product 1    Product 2    Product 3

Day 1    5000     5859.99    6001.75
Day 2    5555     7750.99    6000.50
Day 3    5877    5559.30    6578.98

i posted this in a different thread but seems the suggestion are too advance for me? i just want it simple and easy to explain.

i am a bit confuse, so i hope you guys can advice me

so so far what i've done is this;



the problem with the above code is that, the amount "5000" won't appear,

the output will look like this;


       Product 1    Product 2    Product 3

Day 1     5859.99    6001.75

Question: what should i do in order that the amount "5000" will be included in the second FOR loop?


so in my own way, for me to get the "5000" amount i modified the code to like this, and that's the time i got all the amount on day 1.



 
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
There's so much wrong with that code that the best advice anyone can give you is to dump it and start again.

Campbell's usual advice is to write down the steps that you will need to do on a piece of paper. Then refine each step into smaller steps. Keep doing this until all the steps consist of a few one or two syllable words. Don't write any code until you've done this.
Then switch to Fred's usual advice. For each step you have defined, write a few lines, compile them and test them and only when they do exactly what you want should you move on to the next step.

If you do things like this, then when you do come across a problem, you can narrow it down to exactly where in the code it is and then you will only need to post that bit of code on these forums. The less code you need to post to explain the problem, the easier it is for other people to scan the code and spot what the problem is.
 
Marshal
Posts: 75637
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
I think you ought to continue on the original thread. I shall close this one, and copy your post onto the old thread.
 
Campbell Ritchie
Marshal
Posts: 75637
354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
Have you been taking lessons from Rob, Joanne?
There I was, closing threads so I could write about pencils elsewhere and you manage to slip in a post before me!

If you click the link in that previous line, you get to the location where I copied that post.
 
Hoo hoo hoo! Looks like we got a live one! Here, wave this tiny ad at it:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
    Bookmark Topic Watch Topic
  • New Topic