Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package lista.Alapok;
- public class Main {
- public static int getEvenDigitSum(int number) {
- int count, last;
- if (number<0) return -1;
- else {
- count=0;
- last=0;
- while (number>0){
- if (number%2==0){
- last=number%10;
- count+=last;
- }
- number /= 10;
- }
- } return count;
- }
- public static void main(String[] args) {
- System.out.println(getEvenDigitSum(2114122));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement