Lab exponential
import javax.swing.JOptionPane;
public class p7
{
public static void main(String[] args)
{
double n1=1,i,n2=1,count=1,count2=1,all=0,summ=0;
String sum=JOptionPane.showInputDialog("Enter a n!:");
double n = Integer.parseInt(sum);
System.out.println("N= " +n);
n2=n;
for (i=0;i<10;i++)
{
count=count*n1;
summ=n2/count;
System.out.print(summ+ " + ");
all=all+summ;
n2=n2*n;
n1++;
}
all=all+1;
System.out.println("");
System.out.println("exp= " +all );
}
}
public class p7
{
public static void main(String[] args)
{
double n1=1,i,n2=1,count=1,count2=1,all=0,summ=0;
String sum=JOptionPane.showInputDialog("Enter a n!:");
double n = Integer.parseInt(sum);
System.out.println("N= " +n);
n2=n;
for (i=0;i<10;i++)
{
count=count*n1;
summ=n2/count;
System.out.print(summ+ " + ");
all=all+summ;
n2=n2*n;
n1++;
}
all=all+1;
System.out.println("");
System.out.println("exp= " +all );
}
}
0 Comments:
張貼留言
<< Home