/****************************************************** 割り算の商の表示 *******************************************************/ import java.text.*; public class PrintDivision { public static void main(String[] args) { int a,b; double f; a=10; b=4; f=(double)a/b; // キャストによる型変換 // int型の値を一時的にdouble型として計算する System.out.print("a="); System.out.print(a); System.out.print("\n"); System.out.print("b="); System.out.print(b); System.out.print("\n\n"); System.out.print("割り算をします\n"); DecimalFormat fm03=new DecimalFormat("#,###.000"); System.out.print("a÷b="); System.out.print(fm03.format(f)); System.out.print("\n"); } }