I am working on this recursive function, and I am drawing a blank. Line 15 else if(s.charAt(0) != s.length () -1 && ............ )) Is there a String method that looks for intergers ? Suppose to look to see if it is the last value and if it is a Integer, if it is , add the vaules that intergers together for a total sum public class Finder { //Write two recursive functions, both of which will parse any length string that consists of digits and numbers. Both functions //should be in the same class and have the following signatures. //use the if/else statement , Find the base case and -1 till you get to base case //recursive function that adds up the digits in the String public static int sumIt(String s) { int sumOfNumbers =0; //if String length is less or equal to 1 retrun 1. for (int i = 0; i >= 0 ;i++) if (s.length()<= 1)//Base case = 1 return 1; //else if the CharAt(value in index at 0 = 1) is not equal to the last vaule in the string else if(s.charAt(0) != s.length () -1 && )) sumOfNumbers = sumOfNumbers += Character.getnumericVaule(s.charAt(i)); return sumOfNumbers ; }
I am working on this recursive function, and I am drawing a blank.
Line 15 else if(s.charAt(0) != s.length () -1 && ............ )) Is there a String method that looks for intergers ? Suppose to look to see if it is the last value and if it is a Integer, if it is , add the vaules that intergers together for a total sum
public class Finder { //Write two recursive functions, both of which will parse any length string that consists of digits and numbers. Both functions //should be in the same class and have the following signatures. //use the if/else statement , Find the base case and -1 till you get to base case //recursive function that adds up the digits in the String public static int sumIt(String s) { int sumOfNumbers =0; //if String length is less or equal to 1 retrun 1. for (int i = 0; i >= 0 ;i++) if (s.length()<= 1)//Base case = 1 return 1; //else if the CharAt(value in index at 0 = 1) is not equal to the last vaule in the string else if(s.charAt(0) != s.length () -1 && )) sumOfNumbers = sumOfNumbers += Character.getnumericVaule(s.charAt(i)); return sumOfNumbers ; }

Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 1 images









