• 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

Assignment oop 1

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
can anyone please help me on assingment no 8 daysold.....
i m not able to develop the code for it can anyone please help me on this that how can i develop a programm to calculate how many days old i am....

question is :-
Write a program that tells you how many days old you are.

See www.javaranch.com/common.jsp and look for the GDate and JDate classes. Creating objects from these classes will help you to complete this assignment. You will need to download jr.jar and work it into your classpath in order to use these classes.

In other words, I want to type

java DaysOld 2000-1-2
and see
You were born on January 2, 2000
Today is November 18, 2000
You are now 321 days old.
(with the correct information for the dates and number of days)

To get this to work, you must properly configure your classpath. If you write all of these programs in the C:\Java directory, you could put the .jar file in the same directory and change your classpath to "C:\Java;C:\Java\jr.jar". Be sure to put "import com.javaranch.common.* ;" at the top of your DaysOld.java file.
 
Ranch Hand
Posts: 859
IBM DB2 Chrome Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

i m not able to develop the code for it



I think that's the point.

If you don't at least post something you've tried, no one is going to do it for you.

WP
 
Rishal Dev Singh
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i m not asking for the exact code i am just asking some help like how can i subtract those two dates current one and the one which i provide
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is the Ranch Office forum -- which is for questions for the discussion of Javaranch/Coderanch itself. Please post topics in the correct forum.

https://coderanch.com/how-to/java/CarefullyChooseOneForum


Regardless, let me move this topic for you...

Henry
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rishal Dev Singh wrote:i m not asking for the exact code i am just asking some help like how can i subtract those two dates current one and the one which i provide



Have you taken a look at the methods of the java.util.Date and java.util.Calendar classes? There are some methods which can be used to achieve what you want.

Henry
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Generally, we ask that you cite your sources. This question comes directly from our own cattle drive.

The first step in writing a program is to analyze and understand what they are asking. So, forget about java. How would YOU calculate how many days old you are? Start off very general, but actually write (or type) the steps down. Then, post what you got here.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic