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

 

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

Write a method that returns the difference between the digits in the ones places of 'num1' and 'num2' (which are the parameters passed into the method). Note that this difference will not be negative. Look at the test data for examples. For example, if num1=24925 and num2=142, the difference is 3 because 5-2=3. Likewise, if num1=142 and num2=24925, the difference is STILL 3 (not -3). As preconditions, you may assume that num1 and num2 are both positive numbers. Don't forget to look at the test data for additional examples!


test2022_10_06_APP1SLHL_onesDiff(23521, 5326) → 5
test2022_10_06_APP1SLHL_onesDiff(8932, 1249) → 7
test2022_10_06_APP1SLHL_onesDiff(93235, 12412) → 3

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

public int test2022_10_06_APP1SLHL_onesDiff(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