Monday, October 4, 2010

BlueJ Program On Series x/2!+x/4!+x/6!+....n Terms


Program: Find the sum of the following series using BlueJ.

x/2!+x/4!+x/6!+....n terms


class BlueJS
{
public void show(int x,int n)
{
double sum=0;
int f;
for(int i=2; i< =n; i=i+2)
{
f=fact(i);
sum=sum+(double)x/f;
}
System.out.println("Sum of the series=" + sum);
}
 int fact(int n)
{
int f=1;
for( int i=2 ; i< = n; i++)
{
f=f*i;
}
return f;
}
}

Back To BlueJ Series Display Programs Home Page: CLICK HERE

20 comments:

  1. i'm so sorry...der has been an error from my side in typing in the patterns...they should be something lyk:

    --------------1----------
    -------------333---------
    ------------55555--------
    -----------7777777-------
    ----------999999999------
    -----------7777777-------
    ------------55555--------
    -------------333---------
    --------------1----------

    ReplyDelete
  2. i'm so sorry..there has been an error on my side while typing in the patern..it should be somehing luk:


    ------------1--------
    -----------2_2-------
    ----------3_3_3------
    ---------4_4_4_4------
    --------5_5_5_5_5-----
    ---------4_4_4_4------
    ----------3_3_3-------
    -----------2_2--------
    ------------1----------

    THE UNDERSCORES REPRESENT "SPACES".

    i would also appreciate it if you could
    explain to me the logic behind the program.

    ReplyDelete
  3. pls can you help me print da following pattern:

    -----------1234567--------
    ------------23456--------
    -------------345----------
    --------------4-----------
    -------------345----------
    ------------23456---------
    -----------1234567---------

    ReplyDelete
  4. can you pls help me write a program to print the multiplication table from 11-15

    ReplyDelete
  5. can anyone pls help me write da following programs:
    1) write a program to print the prime numbers from 2 to 100.

    2)write a program to find the largest even number and smallest odd number from a list of
    'n' numder of terms given by the user and indicates the number of numerals to be accepted.

    3)write a program to display all square numbers between 5 to 100.

    5)write a pragram to display the prime palindromes existing in the range of 100-500.

    ReplyDelete
  6. can anyone pls help me wid this '*' pattern:
    --------*****--------
    --------*----*---------
    --------*----*--------
    --------*****--------

    ReplyDelete
  7. pls help

    ............*..........
    ...........***.........
    ..........*****........
    .........*******.......
    ..........*****........
    ...........***.........
    ............*..........

    ReplyDelete
  8. can some one pls help:

    -------------0----------
    ------------101---------
    ---------- 21012--------
    ----------3210123-------

    ReplyDelete
  9. You will get the answer in my next post

    ReplyDelete
  10. need help for dis pattern:

    ----------********---------
    ----------***--***----------
    ----------**----**---------
    ----------*------*---------
    ----------**----**----------
    ----------***--***----------
    ----------********----------

    ReplyDelete
  11. for all the patterns, wait for my next posting.

    ReplyDelete
  12. Please make a program for this pattern too-
    abcdcba
    abc cba
    ab ba
    a a
    ab ba
    abc cba
    abcdcba

    ReplyDelete
  13. class Pat
    {
    int i,j,x,k,n=-1;
    void show()
    {
    for(i=0;i<4;i++)
    {
    x=97;
    for(j=0;j<4-i;j++)
    {
    System.out.print((char)x);
    x++;
    }
    if(i==0)
    x=x-1;
    for(k=0;k=97)
    System.out.print((char)x);
    }
    System.out.println();
    }

    n=3;
    for(i=1;i<4;i++)
    {
    x=97;
    for(j=0;j<=i;j++)
    {
    System.out.print((char)x);
    x++;
    }
    if(i==3)
    x=x-1;
    for(k=0;k=97)
    System.out.print((char)x);
    }
    System.out.println();
    }

    }
    public static void main(String args[])
    {
    Pat ob=new Pat();
    ob.show();
    }
    }

    ReplyDelete
  14. i want for dis pattern
    MORAL
    MORA
    MOR
    MO
    M

    ReplyDelete
  15. class Pat
    {
    String str="MORAL";
    int i,j,len;
    void show()
    {
    len=str.length();
    for(i=0;i<len;i++)
    {
    for(j=0;j<len-i;j++)
    {
    System.out.print(str.charAt(j));
    }
    System.out.println();
    }
    }
    public static void main(String args[])
    {
    Pat ob=new Pat();
    ob.show();
    }
    }

    ReplyDelete
  16. plz help
    1
    21
    321
    4321
    54321

    ReplyDelete
    Replies
    1. class Sum
      {
      public void show()
      {
      int i,j,x=1,y;
      for(i=0;i<5;i++)
      {
      y=x;
      for(j=0;j<=i;j++)
      {
      System.out.print(y--);
      }
      x++;
      System.out.println();
      }
      }
      }

      Delete
  17. plz help
    1
    2 3
    4 5 6
    7 8 9 10

    ReplyDelete
    Replies
    1. class A
      {
      int i,j,x=1;
      void show()
      {
      for(i=0;i<4;i++)
      {
      for(j=0;j<=i;j++)
      {
      System.out.print(x+" ");
      x++;
      }
      System.out.println();
      }
      }
      }

      Delete
  18. There are two programs. can any body answer?
    1
    1 0
    1 0 1
    1 0 1 0
    1 0 1 0 1
    and
    1 2 3 4 5 6 7
    1 2 3 4 5
    1 2 3
    1

    ReplyDelete

Subscribe via email

Enter your email address:

Delivered by FeedBurner