close

問題描述:
試撰寫一程式,可由鍵盤輸入英哩,程式的輸出為公里,其轉換公式如下:
1 英哩= 1.6 公里

輸入說明:
輸入欲轉換之英哩數(int)。

輸出說明:
輸出公里(double),四捨五入取到小數點以下第一位。

範例:

題目來源: http://e-tutor.itsa.org.tw/e-Tutor/mod/programming/view.php?id=6870

import java.util.Scanner;
public class C_MM06 {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		while(scanner.hasNext()){
			int a=scanner.nextInt();
			System.out.println((double)(Math.round(a*1.6*10))/10);
		}
		scanner.close();
	}

}

 

arrow
arrow
    文章標籤
    ITSA Java
    全站熱搜

    阿雅 發表在 痞客邦 留言(0) 人氣()