Computer Science, asked by kanika091, 1 year ago

write a program in java to print the sum of the pattern: s=1/2+3/4+5/6.........+19/20

Answers

Answered by arhamjainmk
21

class Series

{

   public static  void main()

   {

       double a=1.0,b=2.0;

       double s=0.0,s1=0.0;

       System.out.println("the terms are");

       for(int i=1;i<=10;i++)

       {

           s1=(a/b);

           System.out.println(s1);

           s=s+s1;

           a+=2;

           b+=2;

       }

       System.out.println("");

       System.out.println("the sum is "+s);

   }

}

Similar questions