September 29, 2018

# Write a java program to calculates the sum of squares in given digit

Write a java program to calculates the sum of squares in given digit. Write a program that accepts a positive number as input and calculates the sum of squares of individual digits of the given number.

** Input and Output Format:**

Input consists of an integer.

Output consists of an integer.

**Sample Input:**

321

**Sample Output:**

14

## java program to calculates the sum of squares in given digit

package com.demo; import java.util.*; public class Main { private static Scanner sc; public static void main(String[] args) { sc = new Scanner(System.in); int n = sc.nextInt(); getvalues(n); } public static void getvalues(int n) { int a = n; int rem = 0; int sum = 0; while (a != 0) { rem = a % 10; sum = sum + (rem * rem); a = a / 10; } System.out.println(sum); } }