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

 

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

Write a method that returns the "funny sum" of the digits of 'num'. The "funny sum" is found by getting the weighted sum of each digit in the number. The weighting is dependent on the place value of the number. The weight of the digit in the 1's place is 1. The weight of the digit in the 10's place is 2. The weight of the digit in the 100's place is 3. The weights continue to go up by 1 each time the place value gets multiplied by 10. For example, the "funny sum" of 452 is 24 because 2+5+5+4+4+4=24. The 2 had a weight of 1, so it only counted once. The 5 (in the 10's place) had a weight of 2, so it counted twice. The 4 (in the 100's place) had a weight of 3, so it counted three times. Look at the test data for further examples.


test2022_11_03_P1SLHL_funnySumDigits(14966) → 66
test2022_11_03_P1SLHL_funnySumDigits(954) → 41
test2022_11_03_P1SLHL_funnySumDigits(53) → 13

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

public int test2022_11_03_P1SLHL_funnySumDigits(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: 250

Copyright Nick Parlante 2017 - privacy