write a program in Java to find the sum of given series :
1 + 4 + 9 +..................+400
Answers
Answered by
24
HERE is a java program
.........
import java.io.*;
class SquareSeries
{
public static void main(String args[]) throws IOException
{
int n;
BufferedReader br = new
BufferedReader(new InputStreamReader(System.in));
System.out.println(\"Enter no.of elements in series: \");
n = Integer.parseInt(br.readLine());
if(n>0)
{
System.out.println(\"Series:\");
for(int i=0; i<(n-1); i++)
{
System.out.println(\"\\t\"+(int)(Math.pow(i,2)));
}
}
else
System.out.println(\"You Entered the Wrong no.\");
}
}
.........
import java.io.*;
class SquareSeries
{
public static void main(String args[]) throws IOException
{
int n;
BufferedReader br = new
BufferedReader(new InputStreamReader(System.in));
System.out.println(\"Enter no.of elements in series: \");
n = Integer.parseInt(br.readLine());
if(n>0)
{
System.out.println(\"Series:\");
for(int i=0; i<(n-1); i++)
{
System.out.println(\"\\t\"+(int)(Math.pow(i,2)));
}
}
else
System.out.println(\"You Entered the Wrong no.\");
}
}
Similar questions
Geography,
8 months ago
Social Sciences,
8 months ago
Math,
8 months ago
Hindi,
1 year ago
India Languages,
1 year ago