///////////////////////////////////////////示例
import java.math.*;
import javax.swing.*;
public class BigIntegerTest
{
public static void main(String[] args)
{
String input=JOptionPane.showInputDialog("How many numbers do you need to
draw?");
int k=Integer.parseInt(input);
input=JOptionPane.showInputDialog("How many numbers do you need to draw?");
int n=Integer.parseInt(input);
BigInteger lotteryOdds=BigInteger.valueOf(1);
for(int i=1;i<=k;i++)
lotteryOdds=lotteryOdds
.multiply(BigInteger.valueOf(n-i+1))
.divide(BigInteger.valueOf(i));
System.out.println("Your odds are 1 in "+lotteryOdds+" . Good luck!");
System.exit(0);
}
}
a=BigInteger.valueOf(100); )。
但是不能用+ - * / 运算符。必须用类中的方法(BigInteger c=a.add(b);)。
////////////BigInteger
//BigInteger add(BigInteger other)
//BigInteger subtract(BigInteger other)
//BigInteger multiply(BigInteger other)
//BigInteger divide(BigInteger other)
//BigInteger mod(BigInteger other)
//BigInteger compateTo(BigInteger other)
////////////////BigDecimal
//BigDecimal add(BigDecimal other)
//BigDecimal subtract(BigDecimal other)
//BigDecimal multiply(BigDecimal other)
//BigDecimal divide(BigDecimal other)
///////////////////////////////////////////
import java.math.*;
import javax.swing.*;
public class BigIntegerTest
{
public static void main(String[] args)
{
String input=JOptionPane.showInputDialog("How many numbers do you need to
draw?");
int k=Integer.parseInt(input);
input=JOptionPane.showInputDialog("How many numbers do you need to draw?");
int n=Integer.parseInt(input);
BigInteger lotteryOdds=BigInteger.valueOf(1);
for(int i=1;i<=k;i++)
500 Servlet Exception
Note: sun.tools.javac.Main has been deprecated.
/test.jsp:5: Class _jsp.DecimalFormat not found.
DecimalFormat df = new DecimalFormat("##,###,###,###,###,##0.0000000000000");
^
/test.jsp:5: Class _jsp.DecimalFormat not found.
DecimalFormat df = new DecimalFormat("##,###,###,###,###,##0.0000000000000");
^
/test.jsp:9: Variable df may not have been initialized.
String str = df.format(argdouble);
^
3 errors, 1 warning