Computer Science, asked by aditisingh12468, 8 months ago

Write a java program to enter a numbet and check and print whether it is single digit, double digit or four or more digit​

Answers

Answered by monasharma325
2

Answer:

If the number is known to be non-negative:

int digits = Integer.toString(theIntValue).trim().length();

(trim() probably isn't needed.)

If it might be negative:

int digits = Integer.toString(Math.abs(theIntValue)).trim().length();

If you must return a boolean:

boolean isTwoDigit = Integer.toString

Explanation:

public class SchoolTest {

public static void main(String[] args) {

Scanner reader = new Scanner(System.in);

int x;

System.out.println("Please enter a number");

x = reader.nextInt();

if ((x > 9 && x < 100) || (x < -9 && x > -100)) {

System.out.println(true);

main(args);

} else {

System.out.println(false);

main(args);

}

}

}

Similar questions