• Post Reply Bookmark Topic Watch Topic
  • New Topic

arithmetic  RSS feed

 
Kevin Koch
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • 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

 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • 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: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
HINT 2: double = Numbers with decimal places and up to 16 significant digits (I hope that's right)
 
John Jai
Rancher
Posts: 1776
  • Mark post as helpful
  • send pies
  • 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: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Mark post as helpful
  • send pies
  • 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
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!