I need to write a program for a school that converts a Fahrenheit target and vice versa using arguments. I have the following question:
Say the temperature is passed in arg[1], is it possible to apply the conversation equation directly to arg[1]so?
args[1] * 9 / 5 + 32
I tried, but I have an error about the statement *saying: "The * operator is undefined for the type of the argument. I also tried using it "*"instead.
Here is the incomplete code.
Please do not give me the latest code myself, as I want to study, instead of an answer
public class Temperature {
public static void main(String[] args) {
int a = Integer.parseInt(args[0]);
int b = Integer.parseInt(args[1]);
System.out.println("Veuillez specifier c (celsius) ou f (fahrenheit) suivi de la température. Exemple argc arg32");
if (args[0].equals ("c"))
{
int temperature = args[1] *9 /5 +32;
}
else if (args[0].equals ("f"))
{
}
}
}
source
share