Monday, March 27, 2006

Lab Exponential Funtion





package s9226307;
import java.io.*;

public class s9226307
{
public static void main(String[] args) throws IOException
{
BufferedReader keyin= new BufferedReader(new InputStreamReader(System.in));
System.out.println(" Enter the number x of e^x.");
int x = Integer.parseInt(keyin.readLine());
System.out.println("Please make the number n be :");
int n = Integer.parseInt(keyin.readLine());

double p,q,r,s,a,sum=0;
for(p=0;p<=n;p++) { r=1; for(q=p;q>0;q--)
r=r*q;

a=1;

for(s=p;s>0;s--)
a=a*x;
sum=sum+(a/r);
}
System.out.println("e^x = "+sum);

}
}

0 Comments:

Post a Comment

<< Home