Hello and welcome to our community! Is this your first visit?
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Feb 2006
    Thanked 0 Times in 0 Posts

    Question Java variable operations

    I'm programming in Java (not javascript). I'm trying to make a program that inputs money (as a double) and determines the amount of different coins to give. My problem is, I input a value as a double, and try to divide by a number to get the number of times it goes into that number, and get a remainer. For example, using int/int, 7/5 would return 1. But dividing double/double 7.0/5.0 returns an exact double. How to i get int "1" out of that? Thanks!

  2. #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Thanked 163 Times in 160 Posts
    cast the output to an int like this

    quotient = (int) (7.0/5.0);


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts