Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Shavit Borisov
- // CW
- import java.util.Scanner;
- public class DigitCount {
- public static void main(String[] args)
- {
- Scanner in = new Scanner (System.in);
- int digits = 0;
- int num;
- System.out.print("Enter a number: ");
- num = in.nextInt();
- while(num > 0)
- {
- if(num % 2 == 1)
- digits++;
- num = num / 10;
- }
- System.out.printf("The number of odd digits is %d", digits);
- in.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement