Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class E61 {
- public static void main(String[] args) {
- String num = "398898546948";
- char digit = ' ';
- int readableDigit;
- int SumOddDigits=0;
- int index = 0;
- for(index = 0; index < num.length(); index++)
- {
- digit = num.charAt(index);
- readableDigit = Character.getNumericValue(digit);
- if(readableDigit % 2 != 0)
- {
- SumOddDigits = SumOddDigits + readableDigit;
- }
- }
- System.out.println(SumOddDigits);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment