How to input 4 digit number
in scanner class
Answers
Answered by
1
Answer:
import java.util.Scanner;
class Hi
{
void no()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter");
String a = sc.nextLine();
if(a.length()==4)
int b = Integer.parseInt(a)
else
System.out.println("Not a four digit no.");
}
}
Similar questions