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
• Devaka Cooray
• Ron McLeod
• Jeanne Boyarsky
Sheriffs:
• Liutauras Vilda
• paul wheaton
• Junilu Lacar
Saloon Keepers:
• Tim Moores
• Stephan van Hulst
• Piet Souris
• Carey Brown
• Tim Holloway
Bartenders:
• Martijn Verburg
• Frits Walraven
• Himai Minh

What is wrong with my source code?

Ranch Hand
Posts: 186
1
• Number of slices to send:
Optional 'thank-you' note:
Greetings, I have two methods one for converting celsius to farenheit and the other method to convert farenheit to Celsius. I am not having the best of luck with these methods. The equations (listed below) are improperly converting the units. I believe that there may be a possible issue with the way the formulae is written. Can some of you heroes please help assess the code for possible solutions.

Saloon Keeper
Posts: 9742
80
• 1
• Number of slices to send:
Optional 'thank-you' note:
You want 5.0/9.0
As you have it it performs integer division resulting in zero.

Naziru Gelajo
Ranch Hand
Posts: 186
1
• Number of slices to send:
Optional 'thank-you' note:

Carey Brown wrote:You want 5.0/9.0
As you have it it performs integer division resulting in zero.

Excellent, thank you very much for help. I guess that I forgot you can not divide an integer with a double. Thanks for the reminder.

Carey Brown
Saloon Keeper
Posts: 9742
80
• Number of slices to send:
Optional 'thank-you' note:

Naziru Gelajo wrote:

Carey Brown wrote:You want 5.0/9.0
As you have it it performs integer division resulting in zero.

Excellent, thank you very much for help. I guess that I forgot you can not divide an integer with a double. Thanks for the reminder.

Well, yes you can divide an integer with a double, and in that case the integer will be promoted to a double before the divide takes place. Eg 5.0/9
What you have is integer divided by an integer which will throw away any fractional part.