This is a BlueJ Program which displays sum of a series using nested loop.
Back To BlueJ Series Display Programs Home Page: CLICK HERE
import java.util.*;
class Max
{
Scanner sc=new Scanner(System.in);
int n,i,j;
double sum=0;
int s,p;
public void take()
{
System.out.print("\nValue of 'n': ");
n=sc.nextInt();
for(i=1;i< =n;i++)
{
s=0;
p=1;
for(j=1;j< =i;j++)
{
s=s+j;
p=p*j;
}
sum=sum + (double)s/p;
}
System.out.println("\nSum of the series: "+sum);
}
public static void main(String args[])
{
Max ob=new Max();
ob.take();
}
}
Back To BlueJ Series Display Programs Home Page: CLICK HERE
No comments:
Post a Comment