• Post Reply Bookmark Topic Watch Topic
  • New Topic

How to make age cal in java with bufferedreader and inputstreamreader  RSS feed

 
Nix Tacs
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Im having problems in creating an age calculator in java. The only input is your name and date of birth. It means I need to incorporate the current date and make conditions. I need some help, Im only allowed to use BufferedReader, InputStreamReader and IOException for import. I need to start with this and just add the conditions,



I tried to add conditions but its not calculating the days. PLEASE HELP
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, when you add condition what is not working, can you elaborate little more, and please paste your code in code tags.
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can read about code tags here → UseCodeTags.
 
Knute Snortum
Sheriff
Posts: 4288
127
Chrome Eclipse IDE Java Postgres Database VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked for me. Are you using this at the command line or shell?

Scanner may be a better way to get input from the keyboard than BufferedInput.
 
Nix Tacs
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
my professor only advised us to use bufferedreader or java.util.* where I need to use the double data type for double integer.


Im using Jcreator. The current date I used in this program is August 15, 2014. Now, the thing is I need to compute the age of a person using only the dob and it should have an output like this:

------------------------
Enter Your Name:
Date of Birth:
Month:
Day:
Year:
---------------------
Hello + Name!
You are __years, __months and __days old.
------------------------
 
Nix Tacs
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
He havent explained scanne yet, its just bufferedreader and util.*
I dont know what to do.
 
Swastik Dey
Rancher
Posts: 1815
15
Android Eclipse IDE Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Where are you adding condition, in your code we don't see any condition checking, and what your exact output requirement is?
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nix Tacs wrote:my professor only advised us to use bufferedreader or java.util.* where I need to use the double data type for double integer. . . .
I am sure you misunderstood that bit.
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
K. Tsang
Bartender
Posts: 3648
16
Firefox Browser Java Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Nix Tacs wrote:He havent explained scanne yet, its just bufferedreader and util.*
I dont know what to do.


Actually Scanner is in java.util package.

To help you calculate the age thing, probably use the java.util.Calendar to set the 2 dates (user's inputted date and current date). Then ... I will let you figure out (hint Calendar class).
 
Campbell Ritchie
Marshal
Posts: 56600
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Now that the new date/time API is available you will no longer want the Calendar class.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!