Computer Science, asked by joshuajim0306, 5 months ago


write a program in java to display the first 10 terms of the following series 1/2+2/3+3/4+........................+19/20

Answers

Answered by BrainlyProgrammer
2

Series:-

  • 1/2+2/3+3/4+......+19/20

Logic:-

s=s+(I/(I+1))

Code:-

package Coder;

public class Series {

 public static void main(String[] args) {

 int i;

 double s=0;

 for(i=1;i<20;i++)

 {

 if(i!=19)

 System.out.print(i+"/"+(i+1)+"+");

 else

 System.out.print(i+"/"+(i+1));

   s+=(double)i/(i+1);

 }

 System.out.println("\nSum="+s);

 }

}

Variable Description:-

  1. i-----Loop variable
  2. s----to store the sum of the series

•Output attached

Attachments:
Similar questions