This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 19654
    
  18

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'...
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: why is it /by zero???
 
Similar Threads
Can't Break Out of a Loop
Qa dd'rouy Again
writing to a file
static
Introduction and a question about recursion