每天2小时java学习, 今天最后一段要学习的内容是
public class Temperature {
public static void main(String[] args) {
int centigrade = -40; // 摄氏度的初始值为-40
double fahrenheit; // 华氏度
do {
centigrade += 10; // 每行间隔10度
fahrenheit = centigrade * 9 / 5.0 + 32; // 由摄氏度转为华氏度的公式
System.out.println("摄氏温度:" + centigrade + "℃\t华氏温度:" + fahrenheit + "℉");
} while (centigrade < 50);
}
}
网友评论