0

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

4
Contributors
3
Replies
6
Views
13 Years
Discussion Span
Last Post by cms271828
0

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.");
}
}
0

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

0

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

Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.