Question: Write a function in the Java programming language that will take a string that has mixed characters and numbers in it . Your task is

Write a function in the Java programming language that will take a string that has mixed characters and numbers in it.Your task is to find all the numbers in the string and add them up,returning the sum of the numbers extracted from the string. Some helpful functions are the Character.isDigit(char)which will return true if the parameter character is a digit 0-9,and Integer.parseInt(string)that will convert a string to an integer equivalent. No negative numbers will appear in the input string.
For example
findAndAdd("xyz432abc")should return 432.
findAndAdd("xyz432abc444")should return 876.
findAndAdd("123")should return 123.
findAndAdd("11235")should return 12.
findAndAdd("abcxyz")should return 0.
Start of Code:
public class Finder {
public static int findAndAdd(String s){
int result =-1;

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 Programming Questions!