サイコロの出る目の確率
void probbutton_actionPerformed(ActionEvent e) {
int nnum=Integer.parseInt(nField.getText());
int knum=Integer.parseInt(kField.getText());
double prob=0.0;
int cb=comb(nnum,knum);
prob=cb*Math.pow(5.0,nnum-knum)/Math.pow(6.0,nnum);
System.out.println("nCk:"+cb);
rField.setText(Double.toString(prob));
}
comb(nnum,knum);は組み合わせの数 nnumCknum を計算します。