Write a program (using scanner class) to input a line and display only numeric
tokens.
Sample Input: 26 January 1950 is celebrated as Republic day
Sample Output: 26 1950
Answers
Answered by
0
Answer:
Explanation:
import java.util.Scanner;
public class NumToken
{
//main method to test Scanner Class
public static void main(String[] args)
{
System.out.println("Enter line ending with a space & terminate with (.) :");
Scanner in=new Scanner(Sytem.in);
while(true)
{
if(in.hasNextInt());
System.out.print(in.nextInt()+" ");
if(in.next().equals("."))
break;
}
}
}
Similar questions