📄 temperaturedemo.java
字号:
public class temperatureDemo
{
public static void main(String[] args)
{
temperature tempToday=new temperature(-40.0);//today:21.3C
temperature tempYesterday=new temperature('C');//yesterday:0C
temperature tempTomorrow=new temperature(212.0,'F');//tomorrow:30.5F
System.out.println("the temperature of today is "+tempToday.tempValue+tempToday.scale);
System.out.println("the temperature of yesterday was "+tempYesterday.tempValue+tempYesterday.scale);
System.out.println("the temperature of tomorrow will be "+tempTomorrow.tempValue+tempTomorrow.scale);
System.out.println(tempToday.tempValue+tempToday.scale+" equals to "+
tempToday.getTempF()+'F');//need a convert from C to F
System.out.println(tempYesterday.tempValue+tempYesterday.scale+" equals to "+
tempYesterday.getTempF()+'F');
System.out.println(tempTomorrow.tempValue+tempTomorrow.scale+" equals to "+
tempTomorrow.getTempC()+'C');
if(tempToday.wheatherEqual(tempTomorrow))
System.out.println("the tempereature of today is equal to tomorrow.");
else
System.out.println("the tempereature of today is not equal to tomorrow.");
temperature anotherDay=readnew("another day");
temperature nextDay=readnew("next day");
nextDay.reset(136.6,'F');
if(anotherDay.wheatherGreater(nextDay))
System.out.println("the tempereature of anotherDay is greater than nextDay.");
else
System.out.println("the tempereature of anotherDay is not greater than nextDay.");
anotherDay.reset(23.6);
nextDay.reset(136.6,'F');
if(anotherDay.wheatherLess(nextDay))
System.out.println("the tempereature of anotherDay is less than nextDay.");
else
System.out.println("the tempereature of anotherDay is not less than nextDay.");
if(anotherDay.wheatherGreater(nextDay))
System.out.println("the tempereature of anotherDay is equal to nextDay.");
else
System.out.println("the tempereature of anotherDay is not equal to nextDay.");
}
public static temperature readnew(String day)
{
temperature tempDay=new temperature();
System.out.println("Please enter the temperature of "+day+":");
tempDay.reset(SavitchIn.readDouble());
System.out.print("And the scale?");
char newscale=SavitchIn.readChar();
while(newscale!='C'&&newscale!='F')
{
System.out.print("Error scale. Enter again:");
newscale=SavitchIn.readChar();
}
tempDay.reset(newscale);
return tempDay;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -