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 Operator Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Modulus Operator" Watch "Modulus Operator" New topic

Modulus Operator

Shirl Diva

Joined: Sep 09, 2002
Posts: 21
Can anyone give me some insight on Java's modulus operator? If I have code that calculates the interest on the principal amount, why can't I get
the remainder for the division ( I am using all integer values) statement. I am new to java and have been grasping at straws a bit. I seem to be able to get the first digit but not the second one - for the cents. On second thought, can you take a look at the code and let me know where I'm going wrong:

Maybe I don't really understand the modulus operator. I thought that you could divide
2 integers then use the same two to get the
remainder. Please help.

Marilyn added code tags.
[ October 31, 2002: Message edited by: Marilyn de Queiroz ]
Michael Matola
Ranch Hand

Joined: Mar 25, 2001
Posts: 1793
Closing thread in IDEs and moving to Java in General (Beginner).
Jamie Robertson
Ranch Hand

Joined: Jul 09, 2001
Posts: 1879

where is the modulus operator in your code???
Marilyn de Queiroz

Joined: Jul 22, 2000
Posts: 9059
This page might help explain modulo.

"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
I agree. Here's the link:
subject: Modulus Operator
jQuery in Action, 3rd edition