please answer this question
Answers
Search...
Java Programs
Basic Programs:
Hello World Program in Java
Variables Initialization Program in Java
Operators Program in Java
Simple Interest Program in Java
Fahrenheit to Celsius Program in Java
Find Area of Rectangle Program in Java
Find Area Circle Program in Java
Marks Average Program in Java
Swapping Program in Java
Swapping with Two Variables Program in Java
Increment Decrement Operators Program in Java
Mobike Program in Java
If Based Programs:
Voting Age Program in Java
Passing Division Program in Java
Leap Year Program in Java
Greatest Number Program in Java
Greater Number Program in Java
Even Odd Program in Java
Equal Number Program in Java
Switch Based Programs:
Name Of Month in Program Java
Vowels Character Program in Java
Menu Driven Program in Java
Name Of Day Program in Java
Loop Based Programs:
Armstrong Number Program in Java
Automorphic Number Program in Java
Buzz Number Program in Java
Circular Prime Program in Java
CoPrime Numbers Program in Java
Disarium Number Program in Java
Duck Number Program in Java
Factorial Program in Java
Factors Program in Java
Fibonacci Series Program in Java
Floyd Triangle Program in Java
Greatest Common Divisor Program in Java
Happy Number Program in Java
Harshad Number Program in Java
Least Common Multiple Program in Java
Magic Number Program in Java
Multiply Of Digit Program in Java
Neon Number Program in Java
Niven Number Program in Java
Palindrome Number Program in Java
Perfect Number Program in Java
Prime Number Program in Java
Prime Number Up to N Terms Program in Java
Pronic Number Program in Java
Reverse Number Program in Java
Special Number Program in Java
Spy Number Program in Java
Sum of Digits Program in Java
Tech Number Program in Java
Twin Prime Program in Java
Twisted Prime Program in Java
Ugly Number Program in Java
Unique Number Program in Java
Series Programs:
Number Series Program in Java
Even Number Series Program in Java
Odd Number Series Program in Java
Square Number Series Program in Java
Square Post Number Series Program in Java
Square Pre Number Series Program in Java
Pattern Based Programs:
Pattern Type One Program in Java
Pattern Type Two Program in Java
Pattern Type Three Program in Java
Pattern Pyramid Program in Java
Pattern Reverse Pyramid Program in Java
Pattern Diamond Program in Java
Array Based Programs:
First Array Program in Java
Reverse Array Program in Java
Smallest in Array Program in Java
Largest in Array Program in Java
Linear Search Program in Java
Binary Search Program in Java
Bubble Sort Program in Java
Selection Sort Program in Java
Merge Array Program in Java
Matrix Program in Java
String Programs
Sentence Reverse Program in Java
Words in Sentence Program in Java
Words in Sentence Program in Java
Short Name Format Program in Java
Output Questions::
Loop based output questions
---
Home
Java Programs
Square Number Series Program in Java
Square Number Series Program in Java
Square Number Series Program in Java
Square Number Series Program in Java
import java.util.Scanner;
public class SquareNumberSeries
{
public static void main(String[] args)
{
int n,sum=0;
Scanner sc = new Scanner(System.in);
System.out.print("Enter number of terms=");
n = sc.nextInt();
for (int i = 1; i <= n; i++)
{
int t=i*i;
sum=sum+t;
if (n == i)
{
System.out.println(t);
}
else
{
System.out.print(t+"+");
}
}
System.out.println("Sum of series="+sum);
}