Results 1 to 3 of 3
  1. #1
    jim01 is offline Member
    Join Date
    Sep 2010
    Location
    Southwest Missouri
    Posts
    97
    Rep Power
    0

    Default Converting whole number into decimal

    In one of my class exercises, I have to write a program that reads certain employee information and prints a payroll statement. I have to write it once using dialog boxes for input/output and again using console input/output.

    One of the fields is the federal tax withholding rate. I have it set up so that I can enter a number (i.e., 20). What I need to do is convert that 20 into .20 and display it. I know how to display it but cannot figure out how to convert it.:confused:

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    Eastern Florida
    Posts
    17,902
    Rep Power
    25

    Default

    You want to convert 20 to .20? Divide by 100.0
    You want to do floating division not integer division.

  3. #3
    jim01 is offline Member
    Join Date
    Sep 2010
    Location
    Southwest Missouri
    Posts
    97
    Rep Power
    0

    Default

    Quote Originally Posted by Norm View Post
    You want to convert 20 to .20? Divide by 100.0
    You want to do floating division not integer division.
    Float! Of course. That's what I was doing wrong.

    Thank you very much.

Similar Threads

  1. Store the decimal number into an variable
    By fataguila in forum New To Java
    Replies: 4
    Last Post: 02-01-2010, 08:22 PM
  2. A Number Converting Program!
    By WastedxYears in forum New To Java
    Replies: 2
    Last Post: 01-09-2010, 01:47 AM
  3. converting a decimal to an int
    By shuks in forum New To Java
    Replies: 9
    Last Post: 10-12-2009, 10:41 AM
  4. Replies: 3
    Last Post: 07-25-2009, 02:44 PM
  5. Converts a binary number to a decimal
    By cachi in forum New To Java
    Replies: 1
    Last Post: 08-01-2007, 10:57 AM

Posting Permissions

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