answersLogoWhite

0


Best Answer

import java.util.*;
public class tryint{
public static void main(String[] args){
Scanner s=new Scanner(System.in);
int w;
try{
System.out.print("Input number:");
w=s.nextInt();
System.out.print("Input number is "+w);}
catch(Exception wi){System.out.println("not an integer");}
}
}

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How you can restrict the user to input only digits or integers?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is synchronous serial input?

synchronous input means that the flipflop reads input only at posedge or negedge of the clock.


How many strings of three the same digits have exactly three digits that are 9s?

Only 1 exists, and it is "999"


What is a neon number?

a neon number is that wheresum of digits of square of the number is equal to the number ...for example --sample input => 9sample output =>9*9 = 81,8+1=9therefore,9 is a neon numberPRACTICALLY, THERE IS NO OTHER SUCH NUMBER...ITS ONLY A THEORETICAL CONCEPT OF NEON NUMBERS !!


Can an OR gate have one input?

Technically, an OR gate could function with only one input, in which case it would perform the same as if it was not present; when its only input goes high, it would go high, and when the input goes low, it would go low. As a practical matter, the only useful purpose of a single input OR gate would be to have it act as a simple diode, which would be more efficient to simply have a diode in its place.


Will a type cast allow you to convert a double to int without data loss?

No. Not unless the value contained is an integer value, and the number of digits is less than the resolution of the int type. Most doubles support about 15 digits of resolution, while 32 bit integers only support 9. You might be successful in a 64 bit int format, but you still need to consider the maximum value.The only thing the type cast buys you is elimination of the compiler warning. With the type cast, you are telling the compiler that you know what you are doing.

Related questions

Name the only digit that is NOT an integer?

All digits all part of the set of integers.


How many odd integers between 1000 and 8000 have only non zero digits?

How many


How many positive integers less than 1000 are 6 times the sum of their digits?

There is only 1, the number 54.


A 2 digit number that is the product of 2 consecutive integers and the sum of its digits is greater than the product of the digits both digits are even?

The 2-digit number must be 20, because it is the only 2-digit number whose sum of its two even digits, 2 + 0 = 2, is greater than the product of its two even digits, 2 x 0 = 0. Moreover, 20 is a product of the two consecutive integers 4 and 5.


Is 0.364 an integer?

no. Only whole numbers are integers like 1 or 50 or 1000. Any number with no digits on the right of the decimal point is an integer


How many integers between 1 and 10 are dividends of 1000?

1, 2, 4, 5, 8, and 10, so only 6 digits.


How many hex digits are required to represent decimal numbers up to 1 million.proof the answer?

The answer depends on the degree of precision. If only integers are to be represented, then 6 digits would be enough because 165 = 1,048,576 is bigger than a million.


Are all of the digits in the described measurement of 750 mL singnificant?

Integers ending in 0 are ambiguous cases. The measurement could be accurate to the units digit and in that case all three digits are significant. But is could be accurate to the nearest ten, in which case, only the first two digits are significant.


How many numerals between 11 and 999999 contain repeated single digits?

There are 45 integers between 11 and 999999 which consist of only one digit being repeated. There are 831430 integers that contain at least one repeated digit.


What are the only integers that does not have an opposite?

There are no such integers.


What multiplied by 2 equals 86?

If we restrict the discussion to integers (whole numbers), then there are only two possibilities: 1 x 86 2 x 43


What is the largest digits number with only 2 digits alike?

The largest digits number with only 2 digits alike is 99