Win a copy of Java Mock Exams (software) this week in the Programmer Certification (OCPJP) forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Modulus

 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12373
40
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 "=="?
 
James Hambrick
Ranch Hand
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 282
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
What are you doing? You are supposed to be reading this tiny ad!
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!