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):
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.
I love a good mentalist. And so does this tiny ad: