This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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: 1791
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: 9058
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
It's not a secret anymore!