import java.util.*;
import java.lang.*;
import java.io.*;

// The main method must be in a class named "Main".
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int sum = 0 ;
        if(n<0){ n = n * -1 ; }
        while(n>0){
            int n1 = n % 10 ;
            sum = sum + n1 ;
            n = n /10 ;
        }
        System.out.print("Sum = " + sum);
    }
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: