• 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 ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

wrong output

 
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Marshal
Posts: 79470
379
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 56
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Can i get some understanding why you inherit from JPanel, and not JFrame?(anybody help please)
 
Ranch Hand
Posts: 226
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic