package October;
import java.util.Scanner;
public class Common {
public static void main(String[] args) {
Scanner scanner =new Scanner(System.in);
System.out.print("请输入商品价格:");
String str=scanner.next();
StringBuffer str1 = new StringBuffer(str);
//用i记录.的位置向前移动三位插入,
for(int i=str1.lastIndexOf(".")-3;i>0;i-=3){
str1=str1.insert(i,",");
}
System.out.println(str1);
}
}
输入商品价格转换为标准格式
最新推荐文章于 2024-08-18 21:36:31 发布