PDA

View Full Version : I need help with something in my Java class.


SheSheChan
10-11-2007, 10:28 PM
I noticed the Programming forum was taken down so I'm hoping I'm posting this in the right area.

http://img.photobucket.com/albums/v685/sheshechan/ch3ex2.jpg

My mind just went blank, and I would love anyone who could help me out with any part of this. I know what I'm supposed to do but I can't think of what part of the equation would go in the rectangle/rhombus. Or even the equation itself. I can't think of how to get that pattern going. I'm pretty sure the checkmark by it means there's help on the textbook website but I can't find it. =x Thanks anyone~

Squeek
10-12-2007, 02:10 AM
The algorithm is easy. It is addition, after all.

int n = 10;
double x = 1; //Accounts for the initial "1+" step.
while (n > 0) {
x += 1/(n^2);
n--; }

I uninstalled Java on this computer when I quit Computer Science years ago so I can't test this, but it should work.

As for flowcharts, I was never one for explanatory coding. I coded to code. I quit Computer Science because everyone wanted rules and guidelines for how we should code. Also because Assembly Language sucked. Nobody should have rules placed on their coding technique. It's just stupid.

So, I can't help with the flowchart.

Hudelf
10-12-2007, 03:15 AM
As for flowcharts, I was never one for explanatory coding. I coded to code. I quit Computer Science because everyone wanted rules and guidelines for how we should code. Also because Assembly Language sucked. Nobody should have rules placed on their coding technique. It's just stupid.

Wow, my teachers seem to be a helluva lot better than yours were. My teachers have specifically told us that guidelines in coding are too restrictive, and will thus just tell us general conventions to follow, and good coding technique (How to avoid creating hard-to-debug errors, good commenting, etc). They also obviously teach us syntax and such, but never explicit rules to follow.

Also, with regards to your code segment, that should work. Obviously it's missing the class declaration, but that should be a given anyways.

SheSheChan
10-12-2007, 05:43 AM
The algorithm is easy. It is addition, after all.

int n = 10;
double x = 1; //Accounts for the initial "1+" step.
while (n > 0) {
x += 1/(n^2);
n--; }

That's basically what my code looked like, with a few changes here and there. I'm preeeetty sure I got it right though. Thanks for your input though, I got to double check things. =)


What I actually got for psuedocode (we didn't actually have to write the code, we just started with things) was:

input: n

sum <- 0

i <- 1

repeat the following three steps while i < or = to n:

sq = i * i
sum <- sum + 1/sq
i = i + 1

output = sum

The point of doing this was more or less to make it general and usable with any variable.

lord_carbo
10-12-2007, 08:51 PM
Let's not let this thread become obsolete.

ITT the Riemann Hypothesis.

Anyone know some complex analysis?

GuidoHunter
10-13-2007, 01:53 PM
Anyone know some complex analysis?

A little, yes.

At the very least, I have an entire book on it.

--Guido

http://andy.mikee385.com