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

 

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

Write a method that returns the "digit sum difference" of 'num1' and 'num2'. The "digit sum difference" is the sum of all the differences in the digits at specific place-values in the numbers. For example, the "digit sum difference" of 5781 and 239 is 23. The reason is that the difference between the digits in the one's place is 9-1=8; in the 10's place is 8-3=5; in the 100's place is 7-2=5; and in the 1000's place is 5-0=5. So the individual digit differences are 8, 5, 5, and 5. That makes the SUM of the digit differences 8+5+5+5=23. Look at the test data for more examples. As a precondition, you may assume that 'num1' and 'num2' are both positive.


test2021_12_15_SLHL_digitDiffSum(1243433, 2353) → 11
test2021_12_15_SLHL_digitDiffSum(49386, 2141512) → 24
test2021_12_15_SLHL_digitDiffSum(239583, 15123) → 18

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

public int test2021_12_15_SLHL_digitDiffSum(int num1, int num2) { }

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

Copyright Nick Parlante 2017 - privacy