MCPcopy Create free account
hub / github.com/PrajaktaSathe/Java / squareDigits

Method squareDigits

Programs/SquareEveryDigit.java:3–14  ·  view source on GitHub ↗
(int n)

Source from the content-addressed store, hash-verified

1public class SquareDigit {
2
3 public int squareDigits(int n) {
4
5 String strDigits = String.valueOf(n);
6 String result = "";
7
8 for (char c : strDigits.toCharArray()) {
9 int digit = Character.digit(c, 10);
10 result += digit * digit;
11 }
12
13 return Integer.parseInt(result);
14 }
15
16}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected