• 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
  • Paul Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

why is it /by zero???

 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi again... i/ve got a problem with my code... i don't know why it says on the error
Exception in thread "main" java.lang.ArithmeticException: / by zero
at permutation.main(permutation.java:47)

codecodecode:

can anyone help me please??
thank you!!!
 
Sheriff
Posts: 22683
128
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Obviously down is 0, because that's the only divisor. What value for "n" and "r" are you using?
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What are the values of 'r' & 'n', because this is working for me using



C:\Projects\workspace\TestApp\other>java perm 1 0
down: 1, above: 1, under: 1
The permutation of 1 taken 0 is 1

C:\Projects\workspace\TestApp\other>java perm 0 1
own: 1, above: 1, under: -1
he permutation of 0 taken 1 is 1

C:\Projects\workspace\TestApp\other>java perm 0 0
down: 1, above: 1, under: 0
The permutation of 0 taken 0 is 1

C:\Projects\workspace\TestApp\other>java perm 1 1
C:\Kukri\workspace\TestApp\other>ja
down: 1, above: 1, under: 0
The permutation of 1 taken 1 is 1

C:\Projects\workspace\TestApp\other>java perm -1 0
down: 1, above: 1, under: -1
The permutation of -1 taken 0 is 1

C:\Projects\workspace\TestApp\other>java perm 0 -1
down: 1, above: 1, under: 1
The permutation of 0 taken -1 is 1

 
Momo Sawada
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rob Spoor wrote:Obviously down is 0, because that's the only divisor. What value for "n" and "r" are you using?


umm... the user inputs 'n' and 'r'... then the program parses its.. and the integer 'under' is 'n-r'...
 
Slideshow boring ... losing consciousness ... just gonna take a quick nap on this tiny ad ...
Garden Master Course kickstarter
https://coderanch.com/t/754577/Garden-Master-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic