Hello, I am trying to create a java file that will print out the temperature in Fahrenheit. This is my code.
I need to know what I am doing wrong. Using Eclipse as my platform. I have entered comments where I am getting red X's.import java.util.Scanner; public class TemperatureConverter { public static void main(String[] args) { float temperature; Scanner in= new Scanner(System.in); System.out.printf("Enter temperature in degrees Celsius: "); temperature = in.nextInt(); //Getting a red X next to this line. fahrenheit = temperature * 9/5 +32; //Add this line System.out.printf(+temperature + " degrees Celsius is " + fahrenheit + " degrees Fahrenheit."); //System.out.println(temp1 + " degrees celsius is " + fahrenheit + " degrees Fahrenheit."); } }
The error I get when I run the program.
Exception in thread "main" java.lang.Error: Unresolved compilation problems:
fahrenheit cannot be resolved to a variable
fahrenheit cannot be resolved to a variable
at TemperatureConverter.main(TemperatureConverter.jav a:24)