User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the Java section within the Software Development category of DaniWeb, a massive community of 455,962 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,602 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Java advertiser: Lunarpages Java Web Hosting
Views: 1915 | Replies: 3
Reply
Join Date: Nov 2007
Posts: 2
Reputation: gjr1829 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gjr1829 gjr1829 is offline Offline
Newbie Poster

Java date program

  #1  
Nov 16th, 2007
please help me create the first part of date class project.






Date Class Project (part #1)

Create a class named Date

The class has 3 int variables for month, day, and year 05 points
The class has a Boolean value for whether the date is a leap year
private int month;
private int day;
private int year;

write the following “set” methods 15 points
public void setMonth(int m)
public void setDay(int m)
public void setYear(int yyyy) note – year is 4 digits

write the following “get” methods 15 points
public int getMonth()
public int getDay()
public int getYear()

Write the following methods: 10 points
1. public boolean isLeapYear()
this method uses the year variable and returns true
if the year is a leap year. Otherwise returns false.

2. public boolean validateDate() 20 points
a. Returns true if the mm, dd, and yyyy (data items)
compose a valid date
b. Returns false if the mm, dd, and yyyy (data items)
do not compose a valid date

3. public void printDate() 10 points
this method prints out your Date variables in the
following format

month xx
day xx
year xxxx and is (is not) a leap year

create a testing program to test your Date object and its methods.
Name the test program TestDate

Upload the Date.java and TestDate files to Date01 assignment for
evaluation if you wish

Date Class Project (part #2)

Add two constructors to your Date class.

public Date(); 10 points
sets day to 1, month to 1, and year to 1900

public Date(int m, int d, int y); 10 points
sets day to d, month to m, and year to y

create a testing program to test your Date object and its methods.
Name the test program TestDate

Upload the Date.java and TestDate files to Date02 assignment for
evaluation if you wish


Date Class Project (part #3)

Add the following data items to your Date class 05 points
1. int dayOfYear
2. String monthName
3. String dayOfWeek

Add the following methods to your Date class 10 points
1. public void calcDayOfWeek()
Computes the day-of-the-week and stores the day of
week String in the dayOfWeek data item.
(depending in the month, day, and year data items)
2. public String getDayOfWeek() 05 points
returns the day-of-the-week
3. public void calcMonthName() 05 points
Finds the month name and stores the String in the
monthName data item.
4. public String getMonthName() 05 points
returns the month name data item
5. public void calcDOY() 20 points
Calculates the Julian day-of-year and stores it
in the dayOfYear data item.
Examples 01/10/2005 is 10 02/10/2005 is 41
03/01/2005 is 60 03/01/2000 is 61
6. public int getDOY() 05 points
returns the day-of-the-week

7. modify the public void printDate() method to include 05 points
the month name, day of week, and the dayOfYear

month xx (month name)
day xx
year xxxx and is (is not) a leap year
day of week xxxxxxxxx
day of year ddd

8. private void adjustData() that calls the methods 15 points
a. calcDayOfWeek()
b. calcMonthName()
c. calcDOY()
add adjustData() to your constructors and “setMethods()”

create a testing program to test your Date object and its methods.
Name the test program TestDate
Upload the Date.java and TestDate files to Date03 assignment for
evaluation if you wish


Date Class Project (part #4)

Add a constructors to your Date class.

public Date(int doy, int y) 20 points
a. sets year to y
b. using the doy, calculates the month and day
c. runs calcDayOfWeek()
d. runs calcMonthName()

add a method
public String getDateSpelledOut() 10 points

that returns a String with the date in the format

mmmmmmmm nn, yyyy day-of-week

Example November 14, 2008 Wednesday
January 1, 2009 Tuesday


create a testing program to test your Date object and its methods.
Name the test program TestDate

Upload the Date.java and TestDate files to Date04 assignment for
evaluation if you wish

/******************************************************************
*
* program name: Date
* author: Capt. Kirk
* date due: 09/15/2006
* remarks: describes a Box object
*
********************************************************************/
class Date
{
public int month; // store the month
public int day; // store the day
public int year; // store the year

/**********************************
* constructors
***********************************/


/**********************************
* set methods (setters)
***********************************/
public void setMonth(int m)
{
month = m;
}
public void setday(int day)
{
day= m;
}
public void setyear(int year);

public void setyear (int year)
{
year = m;
}

/**********************************
* get methods (getters)
***********************************/
public int getMonth() { return month;}

public intgetDay () {return day;}
public intgetYear() {return year;}


/**********************************
* initialize methods
***********************************/
public boolean calcLeapYear()

{
boolean isLeapYear = true;

if(year %400 == 0

{isLeapYear = true;}

if(year % 100 == 0

{isLeapYear false;}

if (year % 4 == 0

{ isLeapYear true;}
else

{isLeapYear false;}
}

}class TestDate
{
public static void main (String args[])
{

Date d1;
d1 = new date();
Date d2 = new Date();

System.out.println("month is " +d1.getMonth());
System.out.println("day is " +d1.getDay());
System.out.println("year is " +d1.getYear());


d1.setMonth(11);
d1.setDay (11);
d1.setYear(1999);

System.out.println("month is " +d1.getMonth());
System.out.println("day is " +d1.getDay());
System.out.println("year is " +d1.getYear());

}

}
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Nov 2004
Location: Netherlands
Posts: 5,752
Reputation: jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough jwenting is a jewel in the rough 
Rep Power: 19
Solved Threads: 200
Colleague
jwenting's Avatar
jwenting jwenting is offline Offline
duckman

Re: Java date program

  #2  
Nov 17th, 2007
and your question was?
Give us the name, institution, and contact details of your teacher so we can save you the trouble of having to send him the completed homework yourself...
As people are clearly allowed to attack me but I'm not allowed to defend myself, I no longer post to this site.
Reply With Quote  
Join Date: Nov 2007
Posts: 2
Reputation: gjr1829 is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
gjr1829 gjr1829 is offline Offline
Newbie Poster

Re: Java date program

  #3  
Nov 17th, 2007
G, thanks dude
Reply With Quote  
Join Date: May 2007
Location: USA
Posts: 3,076
Reputation: Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold Ezzaral is a splendid one to behold 
Rep Power: 15
Solved Threads: 306
Featured Poster
Ezzaral's Avatar
Ezzaral Ezzaral is offline Offline
Posting Sensei

Re: Java date program

  #4  
Nov 17th, 2007
According to the code that you posted, it was due in September of last year and it describes a Box. I don't think you'll get much credit for this assignment.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Java Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the Java Forum

All times are GMT -4. The time now is 8:59 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC