wood burning stoves*
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
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Modulus" Watch "Modulus" New topic
Author

Modulus

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! http://jameshambrick.com
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 11256
    
  16

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.

http://www.javaranch.com/hundred.jsp
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Modulus