Win a copy of Spring Boot in Practice this week in the Spring forum!
  • 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
  • Tim Cooke
  • Ron McLeod
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Liutauras Vilda
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Al Hobbs
  • Carey Brown
Bartenders:
  • Piet Souris
  • Mikalai Zaikin
  • Himai Minh

arithmetic

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm having an issue with this. "Add the code that calculates the hours, minutes, and seconds needed to download the specified file size at the specified download speed. To do that, start by calculating the download time in seconds and then rounding that value to an integer. Then, divide the total seconds by the number of seconds in an hour to get the number of hours, and divide the remaining seconds by the number of seconds in a minute to get the number of minutes." I know the formula is right there but I just cant get it. I have been up all night trying to get it but I'm not even close. Any help, tips or hint would be great.
Thank you

 
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kevin Koch wrote:Any help, tips or hint would be great.


Yes. Deal with one thing at a time.

First off, your fileSize and downSpeed fields are doubles, but you're using nextInt() to get the values. There's probably nothing terminally wrong with that, but it does seem an odd way to go about things.

But, in answer to your question: Start with secondsPerDl:
Given that you've managed to get the values for fileSize and downSpeed, what should it hold? Are you interested in fractions of seconds? If not, what do you need to do? If you need to, look over the Java Tutorials again.

When you've tried that, come back and show us what you've done.

Winston
 
Kevin Koch
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
So I got some of the math figured out but it is sloppy. It should be 0 hours 13 minutes 20 seconds, but i get a lot of numbers. Once again any help or hints would be great! BTW I did change the nextInt() to nextDouble() thanks for the help!!!





 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kevin Koch wrote:So I got some of the math figured out but it is sloppy. It should be 0 hours 13 minutes 20 seconds, but i get a lot of numbers.


And why do you think that is?

Hint1: What question did I ask after "what should it hold?" in my last post?
Hint2: What kind of value does a double hold?

Winston
 
Kevin Koch
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HINT 2: double = Numbers with decimal places and up to 16 significant digits (I hope that's right)
 
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kevin Koch wrote:HINT 2: double = Numbers with decimal places and up to 16 significant digits (I hope that's right)


Are you referring to number of digits allowed? I was able to declare double with more than 16 digits. I read that it supports 64 bit.
 
Winston Gutkowski
Bartender
Posts: 10780
71
Hibernate Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Kevin Koch wrote:HINT 2: double = Numbers with decimal places and up to 16 significant digits (I hope that's right)


OK, and it seems that you don't want all those digits after the decimal point, right? So, what do you think you have to do?

Winston
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic