⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 rounddecimalplaces.java

📁 Vehicle Maintenance Tracker (VMT) 可以对多个车辆的维护进行跟踪。项目类似于Auto-Do-It
💻 JAVA
字号:
package jMaint;public class RoundDecimalPlaces {    public String RoundDecimalPlaces(float f) {        String s1 = Float.toString(f);        String s2 = null;        if ((s1.length() - s1.indexOf(".") - 1) > 2) {            int y = Integer.parseInt(s1.substring(s1.indexOf(".")+3,s1.indexOf(".")+4));            if (y>4) {                y = Integer.parseInt(s1.substring(s1.indexOf(".")+1,s1.indexOf(".")+3)) + 1;                if (y<10) s2 = s1.substring(0,s1.indexOf(".")+1).concat("0"+Integer.toString(y));                else if (y<100) s2 = s1.substring(0,s1.indexOf(".")+1).concat(Integer.toString(y));                else if (y==100) {                    y = (Integer.parseInt(s1.substring(0,s1.indexOf("."))))+1;                    s2 = Integer.toString(y).concat(".00");                }            } else s2 = s1.substring(0,s1.indexOf(".")+3);        } else if ((s1.length() - s1.indexOf(".") - 1) == 2) s2 = s1;        else s2 = s1.concat("0");        return s2;    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -