I'm trying to create a temperature converter where the user enters a temperature in Fahrenheit and it returns it in Celsius. Here's the code:
import javax.swing.*;
public class tempconv {
public static void main (String[]args) {
int fahr, cel;
String fahrstring;
fahrstring = JOptionPane.showInputDialog(valueof("Enter your temperature in F:"));
fahr = new int[fahrstring];
cel = (fahr - 32) * 5/9;
JOptionPane.showMessageDialog(null, "The temperature in c is " + cel);
}
}
I'm trying to convert the input dialog given into a int but the compiler stops me saying:
error: cannot find symbol
fahrstring = JOptionPane.showInputDialog(>valueof("Enter your temperature in F:"));
so it must be a syntax error. According to the compiler I also got another error saying
tempconv.java:10: error: incompatible types: int[] cannot be converted to int
fahr = >new int[fahrstring];
how would the correct code be written and what exactly am I doing wrong?
valueof("Enter your temperature in F:")should be returning? Why do you think thatnew int[fahrstring]does?