Hi Dani,
fine Examples (the others too) to learn programming Java, but where is the MyInput.java class?
Thanks
Eddi
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.");
}
}
This program consists of one function in one class. It uses MyInput.java to demonstrate how primitive data types are implemented in Java.
I had to do this same program for a homework assignment, except we had to do celcius to fahrenheit.
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
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.