Write a program in Java to find and display the series s=1/2-2/3+3/4-4/5.............n
Answers
Answer:
i am using util package mate,
import.java.util.*;
class series
{
public static void main( String args[] )
{
Scanner sc= new Scanner ( System.in) ;
System.out.println(" enter the end of series "); //to get value of n
int n = sc.nextInt();
int i ;
int r = 1; // used to change the sign
int s= 0; // variable for sum
for ( i=1 ; i<= n; i++) // for loop iteration
{
s= s + r( i/(i+1)) ; // execution of sum
r = -1( r); // sign of next term is changed
}
System.out.println( " sum of series = " + s); // display sum
}
}
hope it helps
plss mark as brainliest