Advertisement
MikelRent

E6.1e

Oct 23rd, 2014
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.33 KB | None | 0 0
  1. package ch6exercises;
  2.  
  3. public class E61e {
  4.  
  5.     public static void main(String[] args) {
  6.         int sum= 0;
  7.         int digit=0;
  8.         int number= 123456789;
  9.         while ( number > 0 )
  10.         {
  11.             digit=number % 10;
  12.             if ( digit %2 == 1 )
  13.             {
  14.                 sum+=digit;
  15.             }
  16.             number/=10;
  17.         }
  18.         System.out.println(sum);
  19.     }
  20.    
  21.  
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement