id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

test2021_04_22_APP1SLHL_someDigitsSum


Write a method that returns the sum of certain digits in 'num'. If 'even' is true, return the sum of the EVEN digits in 'num'. If 'even' is false, return the sum of the ODD digitis in 'num'. As a precondition, you may assume that 'num' is positive.


test2021_04_22_APP1SLHL_someDigitsSum(124523, true) → 8
test2021_04_22_APP1SLHL_someDigitsSum(62882, true) → 26
test2021_04_22_APP1SLHL_someDigitsSum(32833, false) → 9

...Save, Compile, Run (ctrl-enter)

public int test2021_04_22_APP1SLHL_someDigitsSum(int num, boolean even) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 250

Copyright Nick Parlante 2017 - privacy