JAVA to implement numeric uppercase amount conversion method
- 2020-04-01 04:01:15
- OfStack
This article illustrates a JAVA method for converting numeric uppercase amounts. Share with you for your reference. The details are as follows:
Example: to convert an Arabic numeral amount into a capitalized Chinese sum, e.g. :
RMB 1011 - one thousand one hundred and ten one yuan only.
Capital Numbers are: zero, one, two, three, four, five, six, seven, eight, nine, ten, hundred, thousand, ten, hundred
import java.io.*;
import java.lang.String;
public class change
{
public static void main(String agrs[])
{
//Money is used to store the amount of Money entered
long Money=0;
String Mon[]={" zero "," one "," Ii. "," 3 "," boss "," wu "," lu "," Retailer, "," "," nine "};
String Mon1[]={" Pick up "," hk "," micky "," wan "," Pick up all "," One million "," $ "," Hundred million "," Pick up hundred million "," Ten billion "," Thousand million "},
je[]=new String[30];//Je [] array is used to hold the converted number of numeric amounts
//N is used to test whether you have an amount conversion
int n=agrs.length;
if(n==0)
System.out.println(" Please enter the amount to be converted: ");
//Convert the input amount into long data
else
{
Money=Long.parseLong(agrs[n-1]);
}
//Bitt is used to store the number of the amount to be converted,
int bitt=0,j,k=-1,i=0;
//The conversion process
while(Money!=0)
{
bitt=(int)(Money%10L);
//Calculate the capitalization value for each number
for(j=0;j<Mon.length;j++)
{
if(j==bitt)break;
}
//Store the corresponding value in je[]
if(k!=-1){je[i]=Mon1[k];i++;}
je[i]=Mon[j];i++;
Money=Money/10;
k++;
if(Money==0)
{
//Output the converted amount
System.out.print(" The amount you entered is: ");
i--;
for(;i>=0;i--)
System.out.print(je[i]);
}
}
}
}
I hope this article has been helpful to your Java programming.