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

 

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

Write a method that returns the sum of the digits in the specific place value of parameters 'a' and 'b' as indicated by 'place'. As preconditions you may assume that a>=0, b>=0, and that 'place' is a non-negative power of 10 (1, 10, 100, 1000, etc.). For example, if place=100 that means you are to return the sum of the digits in the 100's place of 'a' and 'b'. If place=1000 you return the sum of the digits in the 1000's place. As an additional precondition, you may assume that 'a'>='place' and that 'b'>='place'.


test2023_01_19_P1SLHL_digitSum(100, 1457, 5464778) → 11
test2023_01_19_P1SLHL_digitSum(100000, 54678991, 156478832) → 10
test2023_01_19_P1SLHL_digitSum(100, 457, 321) → 7

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

public int test2023_01_19_P1SLHL_digitSum(int place, int a, int b) { }

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

Copyright Nick Parlante 2017 - privacy