File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Modulus Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Modulus" Watch "Modulus" New topic


James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

I am trying to use Modulus but I cannot get my progam to compile. I seen somewhere on the internet that I should use the format 10 % n, and on the other hand I was shown to use 10 modul n or something like that and it dont work give a compile error Here the statement.

if((10 % n) = 0)

it does not recognize the % symbol. I have not imported anymore libraries. I tried to use
import <java.lang.math.*> but it said that it did not exist.

Visit my blog!
fred rosenberger
lowercase baba

Joined: Oct 02, 2003
Posts: 11814

1) What EXACTLY does the compiler error state?
2) Remember that java is CASE SENSITIVE. math is NOT the same as Math, for example
3) Do you know the difference between "=" and "=="?

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

one moves the value over and one checks for equality.

okay I got that, now im getting a divide by zero error and I know why.
[ May 31, 2007: Message edited by: James Hambrick ]
James Hambrick
Ranch Hand

Joined: Sep 04, 2004
Posts: 282

Im trying to do the Java1b program under Cattle Drive. I got the first part but the formattimg is getting me. I guess Im making it more difficult then it really is.
It is sorta covered in the JavaRanch Style Guide.
subject: Modulus
It's not a secret anymore!