Write a java program to check sum of odd digits.

Write a program to read a number, calculate the sum of odd digits (values) present in the given number.

Check Sum of Odd Digits in java

Input and Output Format: 
Input consists of a positive integer n.
Refer sample output for formatting specifications.
Sample Input 1:


Sample Output 1:

Sum of odd digits is odd.

Sample Input 2:


Sample Output 2:

Sum of odd digits is even.


import java.util.Scanner;
public class Main {
  public static void main(String[] args) {
    Scanner input = new Scanner(System.in);
    int n = input.nextInt();
    int summ=0;
      int remm = n%10;
        summ = summ+remm;
      n = n/10;
      System.out.println("Sum of odd digits is even");
      System.out.println("Sum of odd digits is odd");


Add a Comment

Your email address will not be published. Required fields are marked *

fourteen − ten =