Program in java to print series S=2\1+4\3+6\5...n terms
Answers
import java.util.*;
public class Series
{
public static void main()
{
Scanner sckyu = new Scanner(System.in);
int i,j,n;
double s;
System.out.println("Enter the value of n");
n=sc.nextInt();
{
for(i=2;i<n;i++)
if(i%2==0)
i++;
for(j=1;j<n;j++)
if(i%2!=0)
j++;
}
s=i/j;
System.put.println("Sum of the series is:" +s);
}
}
Question:
Write a program in java to print the series upto n terms_
Answer:
import java.util.*;
public class Series
{
public static void main(String args[])
{
Scanner in =new Scanner(System.in);
int a,b,n;
float S=0.0;
System,out,println("Enter the value of n");
n= in.nextInt();
for(a=2;a<=n;a=a+2)
for(b=1;b<=n;b=b+2)
{
S= S+(a/b);
System.out.println("The series is="+S);
}
}
}
For more java programmings follow the given links, as I have solved earlier:
brainly.in/question/14335606
brainly.in/question/14323927
brainly.in/question/14370842
brainly.in/question/14395545
brainly.in/question/14809512
brainly.in/question/14809885
brainly.in/question/14840551
brainly.in/question/15125968
brainly.in/question/15584326
https://brainly.in/question/15947017