這個怎麼寫代碼啊,一點思路都沒有,怎麼辦啊,求解⋯⋯⋯⋯⋯⋯⋯⋯
借鑒一下,改改。
public static void main(String[] args) {
// TODO Auto-generated method stub
Runtime runtime = Runtime.getRuntime();
System.out.println("占用內存:"
+ (runtime.totalMemory() - runtime.freeMemory()));
long timeStamp = System.currentTimeMillis();
Scanner scanner = new Scanner(System.in);
while (scanner.hasNextInt()) {
int tem = scanner.nextInt();
System.out.println("輸入的華氏溫度是:" + tem);
Integer temperature = (tem - 32) * 5 / 9;
System.out.println("輸出的攝氏溫度是:" + temperature);
System.out.println("消耗時間(包含輸入):"
+ (System.currentTimeMillis() - timeStamp) + "毫秒");
}
scanner.close();
}