[求助]初学JAVA一程序看不懂,请帮下忙
public class TempConvert{
private static double temp;
pvivate static double scale;
static double cToF(double degrees)
{
return 9*degrees/5+32;
}
static double fTOC(double degrees)
{
return 5*(dgrees-32)/9;
}
public static void main(string args[])
{
if (args.length<2)
{
system.out.println("usage:TemConvert number c|F");
ruturn;
}
temp=(new Double(args[0])).doubleValue()
switch(args[1].charAt(0))
{
case 'c':scale="fahrenheit";
temp=cTOF(temp);
break;
case 'F':scale="Celsius";
temp=fTOC(temp);
break;
default:system.out.println("Specify scale as C or F only");
return;
}
system.out.println(args[0])+""+args[1]
+converted to "+temp+"" scale);
return;
}
}
帮忙写上注释,还有那句switch(args[1].charAt(0))
是什么意思,,
static double cToF(double degrees)
{
return 9*degrees/5+32;
}
static double fTOC(double degrees)
{
return 5*(dgrees-32)/9;
}这两句的"degrees"第一次表示的是摄氏度,第二次表示是的华氏温度,请问一个变量怎么可以公用的,想不明白