Thursday, June 24, 2010

Misc : Let me Google that for you

"This is for all those people that find it more convenient to bother you with their question rather than google it for themselves."

Go to the site

Type your question and click the "Google Search" button.

Then you can share the link that's generated on the page.

e.g. searching for "Java for loop" generates:

http://lmgtfy.com/?q=Java+for+loop

Go to the link and watch what happens! :-) Now you send that link to the person who bothered you with the question in the first place.

If you hover your mouse over the link on the lmgtfy page, you see a button for "tinyurl" and "go". The first generates a tinyurl as you would expect and the second shows you what happens when the user clicks on the generated link.

Clicking the "Live Stream" at the bottom shows you what other people are searching for and if you click the dropdown at the bottom you can generate the page in a number of languages.

Now bug off and do your own searches!

Enjoy!

Tuesday, June 22, 2010

Java : FizzBuzz

I regularly read Jeff Atwood's blog and renewed my acquaintance for an old post: Why Can't Programmers.. Program?.

It talks about the Fizz-Buzz question i.e.

"Write a program that prints the numbers from 1 to 100. But for multiples of three print "Fizz" instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of both three and five print "FizzBuzz". "

So I took up the challenge and knocked this out in Java using Netbeans in about 4 minutes.


for (int i = 1; i < 101; i++)
{
int j = i % 3;
int k = i % 5;
System.out.print("Number is " + i);
if (j == 0 && k == 0)
{
System.out.print(" FizzBuzz ");
}
else
{
if (j == 0)
System.out.print(" Fizz ");
if (k == 0)
System.out.print(" Buzz ");
}

System.out.println();
}


So there!

Enjoy!