• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

I need help refining some code

 
Greenhorn
Posts: 25
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,

I recently wrote a program to calculate the time it takes to download a file with a 56k modem. The program looks ok but I would like to refine it so that it gives me the exact time as opposed to a 'rounded off' time.

The program is below:





For example, the time it takes to download a 50MB file is 2hrs 44 mins & 6 seconds. Unfortunately the program I wrote prints out the following:




What is the best way to refine this program so that it gives me the EXACT time instead of 'rounded' numbers?


BTW....I used the "setMaximumFractionDigits()" method in the NumberFormat class but it actually increased the hour by 1. What am I doing wrong? Please help.


Thanks in advance.........

[ September 17, 2008: Message edited by: Derek Harper ]
[ September 17, 2008: Message edited by: Derek Harper ]
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you are using Scanner for input, why aren't you using the % tags for output? A few details here, in the Java Tutorials, and some more in the Formatter class.
 
Campbell Ritchie
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And please use the title of the posts to tell us what they are about: please look at this FAQ.
reply
    Bookmark Topic Watch Topic
  • New Topic