write a program in java using for loop to print following series
Attachments:
Answers
Answered by
3
import java.io.*;
class Series
{
public static void main (String args[])
{
BufferedReader buff = new BufferedReader (new InputStreamReader(System.in));
int a = 2, n, i;
double term = 0.0, sum = 0.0;
System.out.print("Enter the number of
terms: ");
n = Integer.parseInt(buff.readline());
for (i = 0; i <= n; i++)
{
term = term + (1/a);
sum = sum + term;
a += 2;
}
System.out.println(" Sum of the series
is: " + sum);
}
}
Please follow to get more answers!!
class Series
{
public static void main (String args[])
{
BufferedReader buff = new BufferedReader (new InputStreamReader(System.in));
int a = 2, n, i;
double term = 0.0, sum = 0.0;
System.out.print("Enter the number of
terms: ");
n = Integer.parseInt(buff.readline());
for (i = 0; i <= n; i++)
{
term = term + (1/a);
sum = sum + term;
a += 2;
}
System.out.println(" Sum of the series
is: " + sum);
}
}
Please follow to get more answers!!
kritika2727:
Thanks but I need it with a buffered reader
Similar questions