• 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 ...
  • Campbell Ritchie
  • Ron McLeod
  • Rob Spoor
  • Tim Cooke
  • Junilu Lacar
  • Henry Wong
  • Liutauras Vilda
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Tim Holloway
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Al Hobbs
  • Mikalai Zaikin
  • Piet Souris

Don't know where to start???

Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,
Well I'm on yet another assignment. Tell me does this get any easier, everytime I go on in my text I feel soo helpless and lost. I know I'll never take another beginner programming course via correspondence. Too many questions.
So here goes my next problem. Using the Rational class below on rational numbers, I'm suppose to write a test program that will compute the following summation series:
1/1 + 1/2 + 1/3 + ....+ 1/n
1/1 + 1/2 + 1/2e2 +...+ 1/2en

If anyone could help me I would appreciate it. The following is the Rational class (straight from my text):
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's some pseudo-code to help get you started with the first part:

Notice that the "add()" method doesn't modify the base (this) Rational instance, but rather creates and returns a new Rational. That's why you have to do the "sum = sum.add(temp)", rather than just "sum.add(temp)" without the re-assignment.
Doing the second part will be similar, and you might look into the "java.lang.Math" class for useful functions.
Start writing some code and if you run into problems, post what you have and get comments from that. But this should help you start.
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
    Bookmark Topic Watch Topic
  • New Topic