Java determines whether the instance entered by the user contains at least N decimal places
•
Java
Judge whether the entered by the user contains at least N decimal places.
1. Throw an exception and return false when the user enters a non number.
2. When the user enters a number, judge whether the number contains at least N decimal places. If not, return false.
3. Return true when the decimal places of the number entered by the user are greater than or equal to n.
The above example of Java judging whether the user input contains at least N decimal places is all the content shared by Xiaobian. I hope it can give you a reference and support programming tips.
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码