Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner read = new Scanner(System.in);
- int a, b, c = 0,d = 0, sum =0;
- System.out.println("Enter the number");
- a = read.nextInt();
- while(a > 0){
- b = a % 10;
- sum += b;
- if (a%2 ==0)c++;
- else d++;
- a = a/10;
- }
- System.out.println("There are" + c + "even numbers and " + d + " odd" );
- System.out.println("Sum of the digits is " + sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement