This week's book giveaway is in the OCAJP forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide 1Z0-808 and have Jeanne Boyarsky & Scott Selikoff on-line! See this thread for details.
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
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.
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.
I Hear I Forget, I See I Remember, I Do I Understand.
Joined: May 07, 2007
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..
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)
Joined: May 07, 2007
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...