Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions