package snippet;
import java.util.Scanner;
public class Money {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("Please input the number: ");
String word = sc.next();
int length = word.length();
int point = length - 1;//记录小数点位置
char[] chars = word.toCharArray();
for (int i = 0; i < length; i++) {
if (".".equals(chars[i] + ""))
point = i;
}
String mony = "";
int l = 0;
for (int i = 0; i < length; i++) {
if (point != length - 1)
l = 1;
if (!".".equals(chars[i] + "")) {
if (point - i > 8 + l) {
mony = mony + chars[i];
}
if (point - i == 8 + l) {
mony = mony + chars[i] + "亿";
}
if (point - i == 7 + l) {
mony = mony + chars[i] + "千";
}
if (point - i == 6 + l) {
mony = mony + chars[i] + "百";
}
if (point - i == 5 + l) {
mony = mony + chars[i] + "十";
}
if (point - i == 4 + l) {
mony = mony + chars[i] + "万";
}
if (point - i == 3 + l) {
mony = mony + chars[i] + "千";
}
if (point - i == 2 + l) {
mony = mony + chars[i] + "百";
}
if (point - i == 1 + l) {
mony = mony + chars[i] + "十";
}
if (point - i == 0 + l) {
mony = mony + chars[i] + "元";
}
if (point - i == -1) {
mony = mony + chars[i] + "角";
}
if (point - i == -2) {
mony = mony + chars[i] + "分";
}
}
}
System.out.println(mony);
}
}
import java.util.Scanner;
public class Money {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
System.out.println("Please input the number: ");
String word = sc.next();
int length = word.length();
int point = length - 1;//记录小数点位置
char[] chars = word.toCharArray();
for (int i = 0; i < length; i++) {
if (".".equals(chars[i] + ""))
point = i;
}
String mony = "";
int l = 0;
for (int i = 0; i < length; i++) {
if (point != length - 1)
l = 1;
if (!".".equals(chars[i] + "")) {
if (point - i > 8 + l) {
mony = mony + chars[i];
}
if (point - i == 8 + l) {
mony = mony + chars[i] + "亿";
}
if (point - i == 7 + l) {
mony = mony + chars[i] + "千";
}
if (point - i == 6 + l) {
mony = mony + chars[i] + "百";
}
if (point - i == 5 + l) {
mony = mony + chars[i] + "十";
}
if (point - i == 4 + l) {
mony = mony + chars[i] + "万";
}
if (point - i == 3 + l) {
mony = mony + chars[i] + "千";
}
if (point - i == 2 + l) {
mony = mony + chars[i] + "百";
}
if (point - i == 1 + l) {
mony = mony + chars[i] + "十";
}
if (point - i == 0 + l) {
mony = mony + chars[i] + "元";
}
if (point - i == -1) {
mony = mony + chars[i] + "角";
}
if (point - i == -2) {
mony = mony + chars[i] + "分";
}
}
}
System.out.println(mony);
}
}