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

 

jebbert@volusia.k12.fl.us > test2024_03_12_SLHL_funkySum
prev  |  next  |  chance

Write a method that returns the "Funky Sum" of a number. The "Funky Sum" of a number is the sum of all the digits in that number, with the EVEN digits counting as positive values but the ODD digits counting as negative values. It is not about the position of the digits, but rather the even or oddness of the digit that matters. You MUST solve this problem USING RECURSION in a meaningful way. No loops of any kind are allowed! As a precondition, you may assume that 'num' is non-negative. For example, the "Funky Sum" of 64325 is 4 because 6+4-3+2-5=4. Look at the test data for more examples. Remember, RECURSION is REQUIRED. You may also use one or more helper methods. Remember to make sure each method has only one return statement.


test2024_03_12_SLHL_funkySum(0) → 0
test2024_03_12_SLHL_funkySum(5) → -5
test2024_03_12_SLHL_funkySum(2378) → 0

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

public int test2024_03_12_SLHL_funkySum(int num) { }

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: 410

Copyright Nick Parlante 2017 - privacy