我想用 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);
}
}
}
相关分类