Question: Please help me to solve this code check /** * PQ07 Sample Problem. * @author * @version */ public class PQ07S { /** * Write

Please help me to solve this code check

/** * PQ07 Sample Problem. * @author * @version */ public class PQ07S { /** * Write the method sumDigits(). * * The method has one input, a String str, and * returns the sum of the digit characters in the * String. A digit is in the interval [0..9]. You * can convert a digit to an integer by subtracting * '0' (notice this is the char value '0', not "0" or 0). * However, if a digit is a 7, it counts as a 2. * Use a for loop, the charAt() and length() String * methods and if statements. Do not use any other * methods, such as Integer.parseInt() or * Character.isDigit(). If there are no digit characters * in the String, return 0. * * Examples: * sumDigits("aa1bc2d3") returns 6 * sumDigits("aa11b33") returns 8 * sumDigits("Chocolate") returns 0 * * @param str the string to process. * @return the numeric sum as described above. */ // TODO - Write the sumDigits method here.

}

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!