File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes why is it /by zero??? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "why is it /by zero???" Watch "why is it /by zero???" New topic
Author

why is it /by zero???

Momo Sawada
Greenhorn

Joined: Dec 10, 2010
Posts: 24
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!!!
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19794
    
  20

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


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Kevin P Smith
Ranch Hand

Joined: Feb 18, 2005
Posts: 362
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

Joined: Dec 10, 2010
Posts: 24
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'...
 
Don't get me started about those stupid light bulbs.
 
subject: why is it /by zero???