File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes wrong output Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "wrong output" Watch "wrong output" New topic
Author

wrong output

oghenekaro EFEKODO
Ranch Hand

Joined: Oct 10, 2005
Posts: 56
need help in identifying the problem with my program.anytime i run and compute the values i get a wrong answer.thanks for ever listening hears.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37953
    
  22
It is the cast that is the problem; with likely values for p, you end up with a fractional result; if you cast it to an integral number, that converts it to 0. Get rid of the cast and return a double from the comb(int, int, double) method.

[edit] not comb(int, int, double), but binomial(int, int, double) [/edit]
[ November 12, 2006: Message edited by: Campbell Ritchie ]
oghenekaro EFEKODO
Ranch Hand

Joined: Oct 10, 2005
Posts: 56
i removed the casting and it gave me an error message("possible loss of precission").please could you gave me a sample of what to add or to rovemove.thanks in advance.
jide agboola
Greenhorn

Joined: Nov 11, 2006
Posts: 9
Can i get some understanding why you inherit from JPanel, and not JFrame?(anybody help please)


When you are going through Hell, you keep going<br /> <br /> Winston Churchill.
Tim LeMaster
Ranch Hand

Joined: Aug 31, 2006
Posts: 226
Well if you inherit from JPanel you could put this panel in an container you choose. However JFrame is a top level container and has support for window events (like closing), menus, etc.

In this small example I don't think its very important. But you won't find yourself extending JFrame very often if at all. You don't need to extend JFrame to make a swing app - just use the existing class.

Of course this class doesn't need to extend JPanel either it could create it by composition then add the internal JPanel to the Frame.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: wrong output
 
Similar Threads
Multiplying elements of two arrays together
FlowLayout manager wont work
wrong output and exception problem
Multipying array elements together
method construction trouble