使用子字符串java分隔数字

我想用 Java 创建一个程序,从 user_input 获取数字并使其成为货币格式......这是我的代码


package Seperator_checker;


import java.util.Scanner;


public class Seperator {


    public static void main(String[] args) {

        Scanner number=new Scanner(System.in);

        System.out.print("Please Enter Your Number: ");

        String user_number=number.next();

        if(user_number.length()> 3) {

            user_number=user_number.substring(0,user_number.length()-3) + "," + user_number.substring(0,1);

            System.out.println("________________________________________");

            System.out.println("Your Currency Number Is: "+ user_number);

        }


    }


}


蝴蝶不菲
浏览 142回答 2
2回答
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Java