Saturday, September 13, 2008

Digit to Two Letter Word Converter Utility

/*
* A utility for displaying combinations of letter groups, two at a time.
* The user will enter digits (0-9) on a cell-phone numeric pad, letter groups
* for each digits(eg. "ABC", "WXYX" etc are stored in a map using the letter
* key for each. Keys entered at command line by user, are mapped to their
* corresponding values("letter groups") and are retrieved and saved into
* an String array.
*
* The string arry then is passed along with other info to make the combinations.
*
* There is no definate requirement for this utility, so it servs to give a general
* idea of how user input are mapped to values and how they are combined into meaningful
* two-letter words.
*
* Please feel free to call if you need to.
*
* Assumptions: 1.Combination of two letters are to be displayed
* 2. The order of letter-group to be used for first letter doesn't matter.
* eg. if "ABC" "DEF" are entered this utility could either print:
* AD, AE, AF, BD, BE, BF, CD, CE, CF
* or
* DA, DB, DC, EA, EB, EC, FA, FB, FC
*
*
* Author Date Category
* Nirmal Singh Sep. 13th 2008 General/Utilities
*
*
* note: I can produce a more refined version, depending on input/comments in case
* somebody needs this utility for ceartain use.
*
*
*/

package mine_code;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class TwoLetterCombination
{
public static void main(String[] args)
{

getCommandLineArgsProcess(args);
}

private static void getCommandLineArgsProcess(String[] privateArgs)
{
System.out.println("Please enter digits 0-9 and ");
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
String s = null;

try
{
s = in.readLine();
String[] strKeys = new String[s.length()];
int[] intKeys = new int[s.length()];

for(int b=0;b {
strKeys[b] = String.valueOf(s.charAt(b));
intKeys[b] = Integer.valueOf(strKeys[b]);
}

callToCopy(strKeys,intKeys, s);
}

catch (IOException e)
{
e.printStackTrace();
}
//System.out.println("Digits entered are: " + s);
}

public static void callToCopy(String[] strArr, int[] intArr, String s)
{
String[] targetArr = new String[strArr.length];
Map myHash = new HashMap();
for(int g=0;g {
targetArr[g] = strArr[g];

switch (intArr[g])
{
case 0: myHash.put(0, " ");break;
case 1: myHash.put(1, " "); break;
case 2: myHash.put(2, "ABC"); break;
case 3: myHash.put(3, "DEF"); break;
case 4: myHash.put(4, "GHI"); break;
case 5: myHash.put(5, "JKL"); break;
case 6: myHash.put(6, "MNO"); break;
case 7: myHash.put(7, "PQRS"); break;
case 8: myHash.put(8, "TUV"); break;
case 9: myHash.put(9, "WXYZ"); break;
}
}
printCombinations(myHash, s);
}

public static void printCombinations(Map myHash, String s)
{
Iterator it = (myHash.keySet()).iterator();
String[] values = new String[myHash.size()];
int arrSize=0;
System.out.println("Digits entered are: " + s);
System.out.println("The following are digits entered and their corresponding letter"+
"groups: ");
System.out.println();

while(it.hasNext())
{
int key = (Integer)it.next();
values[arrSize] = myHash.get(key).toString();
System.out.println(key + " " + values[arrSize]);
arrSize++;
}

int sizeOfArr =arrSize;
System.out.println();
System.out.println("The following are combinations of the letters: ");
System.out.println("Three blank spaces are stored for each 1 and 0 digits "+'\n'+
"and I am displaying the spaces along with the corresponding "+'\n'+
"letters as part of combination. ");
System.out.println();
for(int m=0; m {
for( int k=0;k {
if(m+1 {
for( int j=0;j {
String tempStr;
char firstChar, secondChar;
firstChar = values[m].charAt(k);
secondChar = values[m+1].charAt(j);
tempStr = firstChar+""+secondChar+"";
System.out.println(tempStr);
}
}
}
}
}
}

Thursday, January 17, 2008

You are Your Site!

In today's world you are who your website says you are. Your website can look how you look and it can tell who you are and how professional you are. The websites these days are not just info portal anymore. Hell ya, the peeps in Graphics Technology aren't learning all the mac tricks for free.

There are a lot of reasons to believe the concept of WYSIWYG. Everybody is popular today(the ones we know) because everybody knows them. How did that happen? Because of their site. Fan clubs didn't do much without websites. They still send post marked letters to their favorite artists in India but the whole picture lacks a real interaction. Not the same thing when we consider the same thing in the web world though. For example, some of my friend can get updates in texts and blogs from people like mahalo, veronica and cooper. How is all that possible? Because of the web. All of these people whom I have mentioned above have a really cool and crisp website which offer really simple sindicate. And they look really nice. Again thanks to the peep sin the graphics technology. Keep up with the good mac work! Bravo.

Okay, let me reaveal the truth...this article was inspired by a website called russell.com. If you don't believe me go there and check it out for yourselves. It is a crappy website. And guess what, there commercial claims that they are world's biggest investment company with over "TWO FREAKING TRILLION" dollars in investment! How is that possible?

In my opinoion, if you ain't got the look you ain't nothing. I am sure most of the people who have an affair with this company do most of their work through the web but I am just surprised how do they put up with this stuff.

If any of you were to go to www.russell.com, you would know yourself that the layout is so cumborsome to use. The pages are not in shape. I had to scroll every four words in a sentence. Honestly, I have been looking at companies like a hawk to work for them on the web but no matter how much russell.com offers me I think I might just say a nah to this one.

Alright let me confess, I am not that great looking but I do have a appreciation for beauty and this site makes me sad; especially when their commercial claims that they are over "two trillion dollars investment company on the globe" at one of the breaks during Larry's talk show on CNN.

Ok, last but not the least. What kinda people get hired to do the web for such companies? Do they even have time to look what they are putting themselves out as in commercials? Do they even notice how they look on the web. You can find a lot many others on the web like that but I thought a worsely designed web portal for big companies like russell.com could be the best example to express my dicomfort in the issue of desig and coordination among the people in IT and the people who just want stuff done. I know I could do a lot better job than that.

Thanks for reading!