Get A Website Plus a Free Domain Name in Just 1 Hour!

Below is the java source code to determine Person's salutation and current age. This program is a good example of Object Oriented Programming, I declared public methods and private variables in the class here. It also has default constructor, constructors, setters and getters or sometimes called as (mutators and accessors) as well as String type methods. Try this java source code that will determine the person's salutation and age.

Java Source Code: Program that will Determine the Person's Salutation and Current Age

If you observed, there were many if-else statements in the method getAge, that is because there are lots of possibilities in the user's input. It is really needed to evaluate and set limitations to each possibility for the program to rightly tell the current age of the person. Below are the sample outputs of the above program.

Note: You can shorten the program by using the java predefined function on calendar, it will directly get the information for the current day, month and year that are set on your computer instead of getting the information directly from the user.