Click here to Skip to main content
15,881,967 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
This is the problem:

Indi wants me to calculate the age of his, but just ask anyone by birth. He remembers that you
You find yourself in the year 1936!

Sorry i'm a begginer xd

They give an example of what I need to have:

-Age: 1905---) His born date can be another number, I mean, It really doesn't metters
-Indi has 31 years

What I have tried:

I tried a lot of things, but my teacher says that the number has to predicted by the user or something like this.
Posted
Updated 29-Sep-22 9:23am
Comments
CPallini 29-Sep-22 5:29am    
"I tried a lot of things, but my teacher says that the number has to predicted by the user or something like this."
Ambiguous requirements lead to nowhere.
Try to better understand (and report) the actual requirements.
Richard MacCutchan 29-Sep-22 5:50am    
Take the current year and subtract the birth year. That will give you the person's approximate age. Reverse the sum to find the year of birth.

1 solution

See here: Working with Age: it's not the same as a TimeSpan![^] - the code is C# rather than Java, but it's pretty simple code and you should have no problem working out what is going on and reworking it for Java and your exact assignment.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900