The program is suppose to convert the input temp. from Fahrenheit to Celsius. So if the input is 212F, then it should display:
212 deg. F = 100 deg. C
Except when I run the program the output is always "0 deg. Celsius". Can someone tell me what I'm doing wrong here? I guessing if anything it has to do with the:
double fahrenheit = keyboard.nextDouble();
But even then I'm not quite sure why. Thanks for your help!
import java.util.Scanner; //keyboard input
import java.text.DecimalFormat; //formatting
public class FahrenheitToCelsius {
public static void main(String[] args) {
Scanner keyboard = new Scanner(System.in);
//User Input
System.out.println("Please enter temperature (Fahrenheit): ");
double fahrenheit = keyboard.nextDouble();
//Calculations
double celsius = (5 / 9) * (fahrenheit - 32);
//Formatting
DecimalFormat myFormatter = new DecimalFormat("#,###.##");
//Output
System.out.println("\n" + myFormatter.format(fahrenheit)
+ " deg. F = " + myFormatter.format(celsius) + " deg. C");
}
}