Farenheit to Celcius

Eddi 0 Tallied Votes 350 Views Share

Hi Dani,
fine Examples (the others too) to learn programming Java, but where is the MyInput.java class?

Thanks
Eddi

package farenheittocelcius;
public class FarenheitToCelcius {
public static void main(String args[])
{
double farenheit, celcius = 0;
System.out.println("\n\tPlease enter temp. in farenheit: ");
farenheit = MyInput.readDouble();
celcius = (5/9)*(farenheit-32);
System.out.println("\n\tThat is " + celcius + " degrees celcius.");
}
}
Dani 4,054 The Queen of DaniWeb Administrator Featured Poster Premium Member

This program consists of one function in one class. It uses MyInput.java to demonstrate how primitive data types are implemented in Java.

Montrell274 0 Newbie Poster

I had to do this same program for a homework assignment, except we had to do celcius to fahrenheit.

cms271828 2 Junior Poster

Hi, looking at your code, I can see only 0 as answer

When you do 5/9, your dealing with ints, so thats 0.

I think you should do 5.0/9 or 5/9.0 or (double)5/9 or 5/(double)9, or or just 0.55555555555555555

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.