sumInfinite() method... HELP!

This is what I have so far, I have no idea that it is right, except for the stuff before the sumFinite() method. Does anyone know how to do the code for the sumInfinite() method? Please help!

import javax.swing.*;

import java.awt.*;

public class Display08 extends JPanel

{

private JLabel label;

private JTextField box1, box2, box3;

public Display08()

{

setLayout(new GridLayout(4, 2));

add(new JLabel("Terms:", SwingConstants.RIGHT));

box1 = new JTextField("", 5);

box1.setHorizontalAlignment(SwingConstants.LEFT);

add(box1);

add(new JLabel("First:", SwingConstants.RIGHT));

box2 = new JTextField("", 5);

box2.setHorizontalAlignment(SwingConstants.LEFT);

add(box2);

add(new JLabel("Ratio:", SwingConstants.RIGHT));

box3 = new JTextField("", 5);

box3.setHorizontalAlignment(SwingConstants.LEFT);

add(box3);

add(new JLabel("Sum:", SwingConstants.RIGHT));

label = new JLabel("");

label.setFont(new Font("Serif", Font.BOLD, 20));

label.setForeground(Color.blue);

add(label);

}

public void sumFinite()

{

double y = Double.parseDouble(box3.getText());

x = Double.parseDouble(box2.getText());

total = x;

for(int alpha = Integer.parseInt(box1.getText());alpha > 0; alpha--)

{

x = x * y;

total = total + x;

}

label.setText("Sum: " + total);

}

}

public void sumInfinite()

{

}

}

[1561 byte] By [javadumbie89a] at [2007-11-27 5:30:55]
# 1

First of all please use code tags as it makes your code much easier to read.

Secondly we are not mind readers, so there is no way for us to know what kind of behavior sumInfinite should have.

Thirdly, we generally don't just hand out code at request here. We are more apt to help you if you show that you at least tried something.

maple_shafta at 2007-7-12 14:55:38 > top of Java-index,Java Essentials,Java Programming...
# 2

I just signed up with this website today... so excuse me that I don't understand how things work around here. If you didn't want to help me then why post anything. And who are you to say that I haven't tried to do anything, I have been working on this program for a week and I have tried things that obviously didn't work, so I didn't bother putting them up.

javadumbie89a at 2007-7-12 14:55:38 > top of Java-index,Java Essentials,Java Programming...
# 3

> If you didn't want to help me then why post anything.

Come on. You asked "Does anyone know how to do the code for the sumInfinite() method?" And maple_shaft correctly pointed out that you hadn't said what the method was supposed to do. That would be helpful to anybody with half a brain... they would respond by posting what it was supposed to do.

But you went on a rant instead. And now you look like more of an idiot. So just cool down and concentrate on the problem. What is the method supposed to do?

DrClapa at 2007-7-12 14:55:38 > top of Java-index,Java Essentials,Java Programming...
# 4

Ok excuse me for going on a rant, I didn't mean to start any kind of argument. I definitely didn't want myself to look like an idiot. But maple_shaft shouldn't have said that I have done anything. But let's move on...

To be honest I don't know what the sumInfinite() method is supposed to do. I got this assignment from this packet, and it doesn't really say anything.

It says this, The sum of an inifinite series (if it has a sum) can be found with the formula first/ 1-ratio. And I don't really know what I'm supposed to do.

javadumbie89a at 2007-7-12 14:55:38 > top of Java-index,Java Essentials,Java Programming...
# 5

> But maple_shaft

> shouldn't have said that I have done anything.

He didn't say you haven't done anything.

His response was perfectly appropriate.

> But

> let's move on...

Yes, let's.

> To be honest I don't know what the sumInfinite()

> method is supposed to do.

Then there's no way anybody here can help you.

> It says this, The sum of an inifinite series (if it

> has a sum) can be found with the formula first/

> 1-ratio.

So you *do* know what sumInfinite is supposed to do.

> And I don't really know what I'm supposed to

> do.

Well, since we don't know what this "packet" is, what istructions you were given, etc., how can we possibly know either? As an educated guess, I'd say you're supposed to create a sumInfinite method that calculates a value as per the formula given above.

jverda at 2007-7-12 14:55:38 > top of Java-index,Java Essentials,Java Programming...
# 6

Please include more information. Calculating the sum of an infinite series isn't trivial; a major method is contour integration, and I suspect that the assignment isn't asking you to write a Risch library.

If you post the problem verbatim, perhaps someone will post a suggestion, although we're really not here to do your homework.

Good Luck!

Joe

Joe_ha at 2007-7-12 14:55:38 > top of Java-index,Java Essentials,Java Programming...
# 7

> Ok excuse me for going on a rant, I didn't mean to

> start any kind of argument.

Yes you did.

> I definitely didn't want

> myself to look like an idiot.

Too late.

>

> To be honest I don't know what the sumInfinite()

> method is supposed to do. I got this assignment from

> this packet, and it doesn't really say anything.

>

Hooray more vagueness.

cotton.ma at 2007-7-12 14:55:38 > top of Java-index,Java Essentials,Java Programming...
# 8

> To be honest I don't know what the sumInfinite() method is supposed to do.

> I got this assignment from this packet, and it doesn't really say anything.

Reminds me of the campus legend about the philosophy final exam.

Inside the exam booklet was the single word, "Why?"

Hippolytea at 2007-7-12 14:55:38 > top of Java-index,Java Essentials,Java Programming...