java - How does number read/spelled as alphabet? ex: 213 as BAC. (jsp) -


i have numbers , 213. want encryption alphabet, 213 bac. when ran codes didn't show anything.

here codes .

calculate.java // java servlet file

         string str = integer.tostring(numbers);          //it because numbers in int type, convert string type first  before spelled                    char[] alp;                     alp = new char[str.length()];              (int = 0; < str.length(); i++) {                         if (str.charat(i)=='1'){                             alp[i]='a';                         }else if(str.charat(i)=='2'){                          alp[i]='b';                          }                                     else if(str.charat(i)=='3'){                             alp[i]='c';                                             }                            else if(str.charat(i)=='4'){                          alp[i]='d';                          }                               else if(str.charat(i)=='5'){                          alp[i]='e';                          }                              else if(str.charat(i)=='6'){                          alp[i]='f';                          }                             else if(str.charat(i)=='7'){                          alp[i]='g';                          }                              else if(str.charat(i)=='8'){                          alp[i]='h';                          }                             else if(str.charat(i)=='9'){                               alp[i]='i';                           }                           else if(str.charat(i)=='0'){                               alp[i]='j';                           }                         else{                             alp[i]=str.charat(i);                         }                     }          out.println("<tr>");                     out.println("<td>");                     out.println("convertion");                     out.println("</td>");                     out.println("<td>");                     out.println(""+str+""); // print output string "str" , what’s wrong this?     // when ran codes, didn't show anything.                      out.println("</td>");                    out.println("</tr>");                  } 

thanks in advance :)

you storing converted character in alp[] array had printed str. please print alp[] array ,

better way using ascii code: pass each single number integer function convert numbers characters , use chars want

private string getcharfornumber(int i) {    return > 0 && < 27 ? string.valueof((char)(i + 64)) : null; } 

and print alp array given below after closing first loop

for (int = 0; < alp.length; i++) {         system.out.print("" + alp[i] + "");     } 

Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -