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

 

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

Write a method that returns the sum of the digits in 'num', except that this sum is reset to zero every time the digit 'tripDigit' appears in the number. For example, if 'num' is 537281, and 'tripDigit' was 7, you would return 11. Adding the digits FROM LEFT TO RIGHT, you would add 5+3 to get 8, but then the next digit is 7, which is the 'tripDigit' so you would reset to zero, then add 2+8+1 to finally get 11. Look at the test data for other examples.


test2025_04_17_SL_tripWire(4621273, 2) → 10
test2025_04_17_SL_tripWire(35232, 2) → 0
test2025_04_17_SL_tripWire(71248, 2) → 12

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

public int test2025_04_17_SL_tripWire(int num, int tripDigit) { }

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

Copyright Nick Parlante 2017 - privacy