五、請問下列 Java 程式輸出為何?(20 分) import java.text.DecimalFormat; public class C3 { public static void main(String[] args) { DecimalFormat d = new DecimalFormat("0.00"); double grosspay = 800.416; System.out.println(d.format(grosspay)); grosspay = 1234.567; System.out.printf("%1.2f", grosspay); } }

詳解 (共 3 筆)

111年警特高普中鋼調查皆上榜
111年警特高普中鋼調查皆上榜
詳解 #5416775
2022/04/14
此題會輸出,四捨五入800.421234...
(共 25 字,隱藏中)
前往觀看
蔡均易
蔡均易
詳解 #3510978
2019/07/27
800.421234.57
(共 15 字,隱藏中)
前往觀看
meleo
meleo
詳解 #5524182
2022/06/24

DecimalFormat("0.00")

取到第二位(四捨五入)

System.out.printf("%1.2f", grosspay); 取到第二位(四捨五入)