hello!!!! help me.. asap...
this is the problem..
how to get five alphabets from user. the program should then be able to translate each letters to its equivalent number. example, a to 1, b to 2, c to 3 until z to 26. note: the program should accept capital letter and small letter like a or A.
3 Replies  1451 Views  Last Post: 14 March 2012  04:43 AM
Replies To: convertion of alphabet letters to numbers in java
#2
Re: convertion of alphabet letters to numbers in java
Posted 14 March 2012  02:40 AM
Read the javadoc for java.lang.Character. Your first job is to ensure that all characters are treated as lower case (or upper case)
This post has been edited by g00se: 14 March 2012  02:56 AM
#3
Re: convertion of alphabet letters to numbers in java
Posted 14 March 2012  02:46 AM
If I am correct ,each characters of alphabet has unique number in in ASCI.
like A is 65, B is 66 so on. a=97, b=98 and so on.
so when user input a character u can check whether it is capital or simple.
Let's say it is simple then we know it is 97 to 122 range. then we can deduce 96 from the converted chart to decimal.
so you know what the number is now.
as an example if it is b,
b is converterd to decimal then it is 98 and deduce 9896 and u get the answer is 2.
you have to find the suitable methode to convert char to decimal in java. since i am not a java programmer.
[url]http://www.asciitable.com/[/url]
like A is 65, B is 66 so on. a=97, b=98 and so on.
so when user input a character u can check whether it is capital or simple.
Let's say it is simple then we know it is 97 to 122 range. then we can deduce 96 from the converted chart to decimal.
so you know what the number is now.
as an example if it is b,
b is converterd to decimal then it is 98 and deduce 9896 and u get the answer is 2.
you have to find the suitable methode to convert char to decimal in java. since i am not a java programmer.
[url]http://www.asciitable.com/[/url]
#4
Re: convertion of alphabet letters to numbers in java
Posted 14 March 2012  04:43 AM
Cast 'a' to Integer to get 97
Cast 'A' to Integer to get 65
The following letters obey this order 'a''z' and 'A' to 'Z'
Read input, check if between 97 and 122
Check if between 65 and 90
Subtract accordingly
Cast 'A' to Integer to get 65
The following letters obey this order 'a''z' and 'A' to 'Z'
Read input, check if between 97 and 122
Check if between 65 and 90
Subtract accordingly
This post has been edited by burakaltr: 14 March 2012  04:44 AM
Page 1 of 1
