这是个问题。 请仅使用switch语句来执行此操作。 这是我的代码。当我运行它时,它会给我错误。错误http://prntscr.com/1dvvr7 的SS帮我看看我的代码d:使用switch语句将温度从华氏温度转换为摄氏温度,反之亦然
public static void main(String[] args)
{
double Degrees_F,f,F;
double DegreesC,c,C;
double x;
int temp;
Scanner keyboard = new Scanner(System.in);
System.out.println("Enter temperature ");
x=keyboard.nextInt();
System.out.println("Enter C or c for Celcius or an F/f for Fahrenheit");
temp=keyboard.nextInt();
switch (temp)
{
case 'C':
Degrees_F = 9*(x/5)+32;
System.out.println(x+"n Fahrenheit is"+Degrees_F);
break;
case 'c':
Degrees_F = 9*(x/5)+32;
System.out.println(x+"n Fahrenheit is"+Degrees_F);
}
}
}
我想你忘了问一个问题。 –
问题是我的代码出了什么问题>。> – xpression
是的,这部分工作有很多错误。它看起来不像是一个诚实的尝试的果实。 –