要求在控制台输入华氏温度或者摄氏温度,转换成相对应的温度。我写的程序如下:运行过后输入数字和字符,回车,就完全没反应了,程序也结束了,请各位大虾帮忙看看哪儿出错了,谢谢咯
import java.util.Scanner;
public class HomeWork1 {
public static void main(String[] args) {
Scanner sca = new Scanner(System.in);
int temperature = sca.nextInt();
String units = sca.next();
if(units == "C"){
int huashi = 5 * (temperature -32) / 9;
System.out.println("华氏温度为:" + huashi);
}else if (units == "F"){
int sheshi = 9* temperature /5 + 32;
System.out.println("摄氏温度为:" + sheshi);
}
}}