Help - Writing program to get Hundredth of a Number

Please support our Java advertiser: Programming Forums - DaniWeb Sister Site
Reply

Join Date: Jun 2008
Posts: 1
Reputation: rayomand is an unknown quantity at this point 
Solved Threads: 0
rayomand rayomand is offline Offline
Newbie Poster

Help - Writing program to get Hundredth of a Number

 
0
  #1
Jun 7th, 2008
Hello

I am new new Java, and would like some help in a exercise I am trying. I would like to know how to get java to print out the "Hundredth" number in a number.
ie in the number 1234 how would I get java to print out that 2 is the 'hundredth' number?

thanks in advanced
ray
Reply With Quote Quick reply to this message  
Join Date: Nov 2006
Posts: 224
Reputation: bugmenot is an unknown quantity at this point 
Solved Threads: 31
bugmenot bugmenot is offline Offline
Posting Whiz in Training

Re: Help - Writing program to get Hundredth of a Number

 
0
  #2
Jun 7th, 2008
you can compute it by dividing by 100 (removes the last 2 digits) and then mod'ing by 10 (only keeps the last digit)
(x / 100) % 10
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Other Threads in the Java Forum
Thread Tools Search this Thread



Tag cloud for Java
About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC