• Post Reply Bookmark Topic Watch Topic
  • New Topic

miles to kilometers conversion with 2 seperate classes.  RSS feed

 
Stephen Carter
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had worked on this one for a while and can't understand why i cant get the return value to my conversion class.


 
Junilu Lacar
Sheriff
Posts: 11477
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The code you gave won't compile. Looks like you need to review how to define methods: http://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, you haven't written any methods.

Do you know how to write methods?
 
Stephen Carter
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I do know how write methods. Sigh, I am making these out to be harder than they really are. I will be back with revised code.
 
Junilu Lacar
Sheriff
Posts: 11477
180
Android Debian Eclipse IDE IntelliJ IDE Java Linux Mac Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

you should also revisit your calculation for kilometers to miles conversion. 16.09 kilometers is 10 miles but your formula won't give that result.
 
Campbell Ritchie
Marshal
Posts: 56533
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Make it simple. Start with a method which takes a double argument and returns a double. Make it really simple; let it return double its argument. When you have got that working give it a sensible name and the correct formula.
1 mile = 63360 × 25.4 ÷ 1000000 km = 1.609344km. That figure is exact.
 
Stephen Carter
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
sorry that i havent gotten back to yall. I spilt my coffee on my keyboard and textbook. I then put the textbook on top of the car to let it dry, but forgot that it was on the roof when we took off down the highway.... it is demolished. sigh.
anyway, I am near to the end of building the code. bbs
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!