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

Java language  Java language Given a string, return the sum of the digits

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!