星期一, 3月 27, 2006

exponential

import javax.swing.*;
public class exponential
{
public static void main(String[] args)
{
double sum = 0;
int n = 1;
double z = 1 ;
String input = JOptionPane.showInputDialog("Enter a number") ;
int inputNumber = Integer.parseInt(input);
for (int j = 1 ; j <=10;j++)
{
n = j * n;
z = inputNumber*z;
sum =sum+ (z/n);
System.out.print(n+" ,");
System.out.print(z+" ,");
System.out.println(sum+" ,");
}
System.out.print("The 10 factorial = "+n+" ,");
System.out.print("The X^10 ="+z+" ,");
sum =sum+1;
System.out.println("Sum = "+sum);
// System.out.println(sum);
}
}


0 Comments:

張貼留言

<< Home

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.5 Taiwan License.