Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.57 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Main {
  4.  
  5.     public static void main(String[] args) {
  6.         Scanner read = new Scanner(System.in);
  7.         int a, b, c = 0,d = 0, sum =0;
  8.         System.out.println("Enter the number");
  9.         a = read.nextInt();
  10.  
  11.         while(a > 0){
  12.             b = a % 10;
  13.             sum += b;
  14.  
  15.             if (a%2 ==0)c++;
  16.             else d++;
  17.             a = a/10;
  18.         }
  19.         System.out.println("There are" + c + "even numbers and " + d + " odd" );
  20.         System.out.println("Sum of the digits is " + sum);
  21.  
  22.  
  23.     }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement