java - 如何显示星号的数量到最接近的千位?

标签 java rounding

    bar1 = store1/1000;
    System.out.print("Store 1: ");
    for(int i = 1; i <= bar1; i++)
        System.out.print("*");

如何显示“*”的数量向上或向下舍入到最接近的千位。现在它只是向下舍入。

最佳答案

使用

bar1 = (store1+500)/1000;
    System.out.print("Store 1: ");
    for(int i = 1; i <= bar1; i++)
        System.out.print("*");

关于java - 如何显示星号的数量到最接近的千位?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28622776/

相关文章:

java - 为什么我的 java KeyListener 不适用于我的 ubuntu?

excel - 如何更改excel四舍五入的小数(默认为0.50,无论小数点前的数字如何,我都需要它向上或向下舍入0.20)

c# - 将任何 n 位数字四舍五入为 (n-1) 个零位

python - 为什么 round(2.49999999999999992) 返回 3

java - Java API 不一致

Java Enhanced-For-Loop 比传统更快?

java - php 和 servlet 应用程序之间的通信

java - 更新 TableView 行外观

java - Jenkins - 如何将覆盖率报告发布到 github

sql - 丢弃时间戳中的毫秒部分