• 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
  • 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
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You want 5.0/9.0
As you have it it performs integer division resulting in zero.
 
Naziru Gelajo
Ranch Hand
Posts: 186
1
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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
Eclipse IDE Firefox Browser MySQL Database VI Editor Java Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

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.
 
My cellmate was this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic