• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

help in java program

 
Shanmugam nagaraj
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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

 
Luigi Plinge
Ranch Hand
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 82
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.................
 
Shanmugam nagaraj
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 441
IntelliJ IDE Scala Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this




Edited to remove code as per Sheriff's suggestion
 
Campbell Ritchie
Sheriff
Pie
Posts: 50175
79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 46
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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...

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic