Welcome to Dream.In.Code
Become a Java Expert!

Join 150,363 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,815 people online right now. Registration is fast and FREE... Join Now!




Formatting Numbers to Indian Rupee with commas

 
Reply to this topicStart new topic

Formatting Numbers to Indian Rupee with commas, Formatting Numbers to Indian Rupee with commas

sph
18 Feb, 2008 - 04:48 AM
Post #1

New D.I.C Head
*

Joined: 18 Feb, 2008
Posts: 1

Indain Rupee System , Groups the lowest three digits
for eg.
1,200
11,200
1,11,200

User is offlineProfile CardPM
+Quote Post

KYA
RE: Formatting Numbers To Indian Rupee With Commas
18 Feb, 2008 - 05:01 AM
Post #2

#include <nerd.h>
Group Icon

Joined: 14 Sep, 2007
Posts: 5,939



Thanked: 159 times
Dream Kudos: 1375
My Contributions
QUOTE(sph @ 18 Feb, 2008 - 06:48 AM) *

Indain Rupee System , Groups the lowest three digits
for eg.
1,200
11,200
1,11,200


DIC would like a good faith effort on your part (can people seriously not read?) before helping. Use [*code] [*/code] tages without the *. I would have a function that converts from the current currency to ruppees, or w/e. It would depend on what the current exchange rate is.
User is online!Profile CardPM
+Quote Post

Jayman
RE: Formatting Numbers To Indian Rupee With Commas
18 Feb, 2008 - 11:14 AM
Post #3

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 7,327



Thanked: 66 times
Dream Kudos: 500
Expert In: Everything

My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: code.gif

Thanks.
User is online!Profile CardPM
+Quote Post

bhandari
RE: Formatting Numbers To Indian Rupee With Commas
18 Feb, 2008 - 11:38 PM
Post #4

D.I.C Addict
Group Icon

Joined: 31 Jan, 2008
Posts: 747


Dream Kudos: 900
My Contributions
As a push start idea, try string class's split() method.
User is offlineProfile CardPM
+Quote Post

Nayana
RE: Formatting Numbers To Indian Rupee With Commas
19 Feb, 2008 - 12:59 AM
Post #5

DIC Hawk - 나야나 नयन:
Group Icon

Joined: 14 Nov, 2007
Posts: 824



Thanked: 5 times
Dream Kudos: 175
My Contributions
I have written a function that does just that, and submitted it as a code snippet. As soon as the code snippet is approved I will post a link to it here.
User is offlineProfile CardPM
+Quote Post

1lacca
RE: Formatting Numbers To Indian Rupee With Commas
19 Feb, 2008 - 05:17 AM
Post #6

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
I would suggest starting from the NumberFormat
User is offlineProfile CardPM
+Quote Post

Nayana
RE: Formatting Numbers To Indian Rupee With Commas
19 Feb, 2008 - 04:15 PM
Post #7

DIC Hawk - 나야나 नयन:
Group Icon

Joined: 14 Nov, 2007
Posts: 824



Thanked: 5 times
Dream Kudos: 175
My Contributions
@1lacca: the NumberFormat class CANNOT format numbers in the Indian way.

Because, in one number, there are 2 seperate digit groupings. NumberFormat only allows 1. So you have to do it youself

@sph
Here is a snippet that formats Indian numbers.



*edit: link removed by 1lacca
User is offlineProfile CardPM
+Quote Post

1lacca
RE: Formatting Numbers To Indian Rupee With Commas
20 Feb, 2008 - 05:05 AM
Post #8

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
QUOTE
@1lacca: the NumberFormat class CANNOT format numbers in the Indian way.

Because, in one number, there are 2 seperate digit groupings. NumberFormat only allows 1. So you have to do it youself


True, I've suggested it so that the op can see how formatting works, and the API doc of NumberFormat has links to Decimal format and all inheriting classes. We generally don't like to provide full solutions before the op demonstrated some effort in solving his problem.

I think you've already seen this sample post:
User is offlineProfile CardPM
+Quote Post

1lacca
RE: Formatting Numbers To Indian Rupee With Commas
20 Feb, 2008 - 05:05 AM
Post #9

code.rascal
Group Icon

Joined: 11 Aug, 2005
Posts: 3,822



Thanked: 12 times
My Contributions
Dream.In.Code has a policy by which we prefer to see a good faith effort on your part before providing source code for homework assignments. Please post the code you have written in an effort to resolve the problem, and our members would be happy to provide some guidance. Be sure to include a description of any errors you are encountering as well.

Post your code like this: code.gif

Thanks.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 01:48PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month