Saturday, April 23, 2011

The key to being happy - in Java

As a programmer, I have to write logic and store data in different languages and environments all the time - HTML, Java, JavaScript, shell script, kjb, BIRT, and XML. A premise I was trying to get across today can be written in Java like this:

int maxHappiness = 100;
int happiness = Integer.parseInt(yourWholeLifeBean.getHappinessAmount());
int satisficationInLife = 0;
if (happiness > 0) {
satisfactionInLife = maxHappiness * (happiness/maxHappiness);
}
return satisfactionInLife;

100% | 174 lbs. | 0% (0 of 128) | 14% (7 of 50) | 30.68% (112 of 365) | 6.444% (12 lbs.)

No comments: