@@ -0,0 +1,953 @@
+package java_problems.beginner;%0D%0A%0D%0Aimport java.util.Scanner;%0D%0A%0D%0A/*%0D%0A * You're given an integer N. Write a program to calculate the sum of all the%0D%0A * digits of N.%0D%0A * %0D%0A * Input: %0D%0A * The first line contains an integer T, total number of testcases. Then follow%0D%0A * T lines, each line contains an integer N.%0D%0A * %0D%0A * Output: %0D%0A * Calculate the sum of digits of N.%0D%0A * %0D%0A * Constraints: %0D%0A * 1 %3C= T %3C= 1000%0D%0A * 1 %3C= N %3C= 100000%0D%0A * %0D%0A * Example %0D%0A * Input:%0D%0A * 3%0D%0A * 12345%0D%0A * 31203%0D%0A * 2123%0D%0A * %0D%0A * Output:%0D%0A * 15%0D%0A * 9%0D%0A * 8%0D%0A */%0D%0Apublic class SumOfDigits %7B%0D%0A%0D%0A%09public static void main(String%5B%5D args) %7B%0D%0A%09%09%0D%0A%09%09Scanner sc = new Scanner(System.in);%0D%0A%09%09int numCases = Integer.parseInt(sc.nextLine());%0D%0A%09%09for (int i = 0; i %3C numCases; i++) %7B%0D%0A%09%09%09String number = sc.nextLine();%0D%0A%09%09%09int sum = 0;%0D%0A%09%09%09for (int j = 0; j %3C number.length(); j++) %7B%0D%0A%09%09%09%09sum += Integer.parseInt(number.charAt(j) + %22%22);%0D%0A%09%09%09%7D%0D%0A%09%09%09System.out.println(sum);%0D%0A%09%09%7D%0D%0A%09%09sc.close();%0D%0A%09%7D%0D%0A%7D

Add SumOfDigits