金额用词 [英] Amount in words

查看:55
本文介绍了金额用词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在java中编写一个程序,如果我输入一个数字,那么数字应该用ex:64 = SixtyFour

I want to write a program in java such a way that if i enter a number the number should be displayed in words ex: 64=SixtyFour

推荐答案

OK显示。您是否尝试过自己编写?
OK. Have you tried writing it yourself?



我想用java编写一个程序,如果我输入一个数字,那么数字应该是以ex:64 = SixtyFour
显示
I want to write a program in java such a way that if i enter a number the number should be displayed in words ex: 64=SixtyFour



好​​。我已经有了一个程序,但我相信你能想出一个更好的方案。所以,试一试,让我们看看你能想出什么。

Good. I already have a program for doing it but I''m sure you can come up with a much better one. So have a go at it and let''s see what you can come up with.


有两种方法(取决于你是否有一个可以输入的最大数字)。如果你做了一系列措辞的数字将很快引用任何数字。


否则你将需要解析每个数字并决定如何显示它。这对于x * 10 ^ 2(x百)数字(比如千万或更大)更容易,但最困难的是y * 10 ^ 1(yty - 因为构造不总是规则的(50) ,三十,二十)所以你必须考虑特殊情况。


希望这会给你一个开始......
There are two approaches (depending on whether you have a maximum number that can be entered). If you do an array of Strings of worded-numbers would quickly reference any number.

Otherwise you will have to parse each number and decide how to display it. This is easy enough for the x*10^2 (x hundred) digit (like wise thousand or anything greater) but the most difficult would be the y*10^1 (y "ty" - because construct not always regular (fifty, thirty, twenty) so you have to think of special cases.

Hopefully this will give you a start.....


这篇关于金额用词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆