• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to make age cal in java with bufferedreader and inputstreamreader

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2236
63
IntelliJ IDE Firefox Browser Spring Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can read about code tags here → UseCodeTags.
 
Sheriff
Posts: 7125
184
Eclipse IDE Postgres Database VI Editor Chrome Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
He havent explained scanne yet, its just bufferedreader and util.*
I dont know what to do.
 
Swastik Dey
Bartender
Posts: 2270
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
Marshal
Posts: 79265
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79265
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Bartender
Posts: 3648
16
Android Mac OS X Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 79265
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Now that the new date/time API is available you will no longer want the Calendar class.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic