Answer:
You are currently showing as a Virtuoso on your profile. Try clearing your cookies and logging back in.
Fair use laws allow you to use other peoples copyrighted info for educational purposes
Answer:
public static String onlyDigits(String in){
String digitsOnly = in.replaceAll("[^0-9]", "");
return digitsOnly;
}
A Complete program is wrtten in the explanation section
Explanation:
public class TestClass {
public static void main(String[] args) {
String a = "-jaskdh2367sd.27askjdfh23";
System.out.println(onlyDigits(a));
}
public static String onlyDigits(String in){
String digitsOnly = in.replaceAll("[^0-9]", "");
return digitsOnly;
}
}
The output: 23672723
The main logic here is using the Java replaceAll method which returns a string after replacing all the sequence of characters that match its argument, regex with an empty string
Well, you didn't say what language, so here's in Java:
public static void PrintShampooInstructions(int numCycles)
{
if(numCycles < 1)
System.out.println("Too few.");
else if (numCycles > 4)
System.out.println("Too many.");
else
{
for(int i = 1; i <= numCycles; i++)
{
System.out.println(i+": Lather and rinse.");
}
System.out.println("Done.");
}
}
And also in an image, in case you can't really see it
B. When the insertion point reaches the right margin