Sum Of Odd Digits

Given an number the task is to find the sum of odd digits present in the number.

Example 1: Let us take a number 83213. Here the sum of odd digits is 3+1+3 = 7.

Java
import java.util.*;
public class OddDigitSum
{
    public static void main(String args[])
    {
        int n=0,r=0,sum=0;
        Scanner sc=new Scanner(System.in);
        System.out.print("Enter a number: ");
        n=sc.nextInt();
        while(n>0)
        {
            r=n%10;
            if(r%2!=0)
            {
                sum=sum+r;
            }
            n=n/10;
        }
        System.out.println("Sum of odd digits: "+sum);
    }
}
Java