aspose file tools*
The moose likes Beginning Java and the fly likes help in java program Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "help in java program" Watch "help in java program" New topic
Author

help in java program

Shanmugam nagaraj
Ranch Hand

Joined: May 07, 2007
Posts: 76
I bit need a help to write this code, based on the table given
- Need to get the name as a input
- After that it want to identify what are the number for each character based on the tabular column given
- And after that need to sum all the identified number, and sum need to go deep like until it ends single number

for example
if I give input as "raj "
then it will identify the number like : r=6, a=1, j=4
and sum it now like 6+1+4=11 and sum it more like 1+1=2
so the number is 2.

Please help at least like what are needs to use to get this outcome with short java program.

1=A,B,C
2=D,E,F
3=G,H,I
4=J,K,L
5=M,N,O
6=P,Q,R
7=S,T,U
8=V,W,X
9=Y,Z


Thanks <br />Shanmugam N
Luigi Plinge
Ranch Hand

Joined: Jan 06, 2011
Posts: 441

Seems like a really easy thing to do using ifs or select case. Do you have a specific problem with Java or are you just looking for someone to do your homework for you?
Roger Fed
Ranch Hand

Joined: Oct 17, 2010
Posts: 82

hello
you must use 'charAt()' method to extract character from string then make "if statements" for talking the appropriate number acording to this character
based on the tabular column
and store this number in anther string.You must do this using loop
after storing all numbers , use 'parseInt()' method in the Integer class.
just try.................


I Hear I Forget, I See I Remember, I Do I Understand.
Shanmugam nagaraj
Ranch Hand

Joined: May 07, 2007
Posts: 76
Hi Roger,
Yeah....
I will try,
But use if else will it be more if else and that why I felt like its not efficient and I think of posting this one to get some expert advice..
Luigi Plinge
Ranch Hand

Joined: Jan 06, 2011
Posts: 441

Try this




Edited to remove code as per Sheriff's suggestion
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Luigi Plinge wrote: . . . or are you just looking for someone to do your homework for you?
Alkways be aware of that risk; as you see
We're all here to learn, so when responding to others, please focus on helping them discover their own solutions, instead of simply providing answers.
(from the "Beginning Java" front page)
. . . so be very careful before posting complete code.
pete reisinger
Ranch Hand

Joined: Dec 30, 2009
Posts: 46
ok,
when you look at it, every letter has a number, so it is a good candidate for a map.
then you can just get value from the map with specific letter and add them together.
this way it seems to be cleaner than "else if" (at least to me)
Shanmugam nagaraj
Ranch Hand

Joined: May 07, 2007
Posts: 76
Hi pete reisinger,
Yeah.. I expected something like these response which help me to think thanks... long time never touch the java code, because of my responsibility changed a bit as .net like share point and moss, recently I got questioned like this and I unable to respond so I think think think now started to come back to learn java again. In my perspective to learn some thing faster is forum that's wju I choose the java ranch (beginner)which I used it before. and dont know why some body get it like this .... may I know where is the place which can what ever I need to get it clear my self... but personally last time java ranch answer me all my questions.. thanks for all responses...

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: help in java program