Question: extractNum description: a method that cleans any non number string from a string it gets and returns the clean string input: -input (string)- a string

extractNum

description: a method that cleans any non number string from a string it gets and returns the clean string

input: -input (string)- a string the method gets

return: string: a string of numbers only

example use:

extractNum("aa2aa3") ==> 23

extractNum("aa2") ==> 2

extractNum("aa10aa") ==> 10

extractNum("aa!!%$#.10aa") ==> 10

hint:

you can use:

Character.isDigit(ch)

or conditions

------------------------

import java.util.*;

class Main {

// your main method here public static void main(String[] args) { Scanner scan = new Scanner(System.in);

System.out.println("Enter s:"); String s = scan.next();

System.out.println(extractNum(s)); }

public static String extractNum(String s) { //your code 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!