简体   繁体   中英

How do I read a floating point value and print the closest numbers less than or greater than that value?

I am having trouble writing a program that reads a floating point value (double) and prints the closest whole numbers less than and greater than that value. For example, if the number is 28.466, the program would print 28 and 29. I want to use Joptionpane to receive the input from the user

您可以使用Math.floor(x)Math.ceil(x)来获取双x的下限和上限。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM