Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 1

/**

* Assignment 3 Question 2
*
*/
import java.io.*;
public class ExtractNumber {
final static char DecimalPoint = '.';
public static void main(String [] args) throws IOException{

int currCh;
boolean found = false;

System.out.printf("Please enter a string as input data:\n");
currCh = System.in.read();

while((currCh != -1) && !(found)){

if(Character.isDigit(currCh)) {
found = true;
while((currCh != -1) && !(Character.isWhitespace(currCh)
)) {
if((Character.isDigit(currCh)) || (currCh == Dec
imalPoint))
System.out.printf("%c", currCh);

currCh = System.in.read();
}
}
currCh = System.in.read();
}//end while


}//end main

}//end class

You might also like