This is a BlueJ Program on series. This program involves nested loop.
import java.util.*;
class Search
{
int
i,j;
double sum=0;
int
x,n;
Scanner sc=new Scanner(System.in);
public void display()
{
System.out.print("\nEnter Value of 'n': ");
n=sc.nextInt();
for(int i=0;i< n;i++)
{
x=0;
for(j=1;j< =i+2;j++)
{
x=x+j;
}
sum=sum + 1.0/x;
}
System.out.println("\nSum of the series: "+sum);
}
public static void main(String args[])
{
Search ob=new Search();
ob.display();
}
}
Back To BlueJ Series Display Programs Home Page: CLICK HERE
No comments:
Post a Comment