|
This simple (first attempt) Java application calculates the number of days, hours, and minutes a person has been alive. The user (you?) puts their birthday in the first three scroll boxes; the next three boxes hold the current date.
Calculating the number of days between two dates may seem trivial on first inspection. But it really is not. The number of days from one year to the next is dependent upon which month and which day the user is using. Also, the fact that Leap Years need to be considered every four years complicates this simple program a bit.
As to the code: there are a lot of performance issues that could be implemented. For example, the use of an array structure to hold the List Box values would reduce hundreds of lines of code to about ten or so - I didn't want to think when I wrote this application from scratch; so, I used a caveman attitude toward getting this thing done. Another improvement might be to add some statistics that would give the user an idea how many days he / she spent sleeping, driving to or from work, or just watching TV using standard percentage values dependent on age, and sex of the user. Also, life expectancy might be calculated given more user input. Well, I suppose I may get around to adding these features someday - but for now; I will fall back on the old standard of software design: "good enough for me ... good enough for you". |
| www. | .com |