Question: Java language Given a string, return the sum of the digits 0-9 that appear in the string, ignoring all other characters. Return 0 if there
Given a string, return the sum of the digits 0-9 that appear in the string, ignoring all other characters. Return 0 if there are no digits in the string. sumDigits("aa1bc2d3") rightarrow 6 sumDigits("aa11b33") rightarrow 8 sumDigits("Chocolate") rightarrow 0 Use the following method signature: Public int sumDigits(String str) {}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
