• 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

miles to kilometers conversion with 2 seperate classes.

 
Greenhorn
Posts: 22
Chrome Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.


 
Sheriff
Posts: 17649
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 79263
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 17649
300
Mac Android IntelliJ IDE Eclipse IDE Spring Debian Java Ubuntu Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79263
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Tell me how it all turns out. Here is a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic