Programming Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsOtherProgramming Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old February 19th, 2007, 11:52 PM
Mrato Mrato is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Feb 2007
Posts: 1 Mrato User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 19 m 47 sec
Reputation Power: 0
Creating a days ,month and year ranges and leap year

Here is the question:
In this practical we will be examining the Doomsday algorithm… one of the simpler
algorithms for mapping an arbitrary date onto a day of the week. For the purposes of this
practical we will be working in the Gregorian calendar (the dominant modern calendar
since 1582). This practical need only function between the years 1800 and 2100
This algorithm exploits the fact that certain dates always occur on the same day of the
week in any given year. The algorithm has three phases, finding the century’s anchor
year, finding the year’s doomsday and finding the day of the week.
1. Create a file Doomsday.java containing a Doomsday class with a set of java
constants for each day of the week, from MONDAY = 0 till SUNDAY = 6
2. The class must contain private members for the Year, Month & Day in question,
these members must be set in the class’ constructor
3. The class must contain a predicate (boolean returning) method isLeap() to
determine if the year is a leap year.
4. The function getAnchorDay() maps the following date ranges onto days
respectively. 1800-1899->Friday, 1900-1999->Wednesday, 2000-
2099->Tuesday, 2100-2199->Sunday,
5. The method getDoomsdayDate() returns an integer representing the date in the
month on which doomsday will fall. These doomsdays are as follows:
Jan – 3 (or 4 if leap year), Feb – 28 (or 29 if leap year)
March – 0 (last day in February), April – 4, May – 9, June - 6
July – 11, August – 8, September – 5, October – 10, November - 7
December – 12
6. The method getDoomsday() calculates the doomsday as follows
y <-last 2 digits of year
a <-y/12]
b <-y mod 12
c <-[b 4]
d <-a +b +c
diff <-DAY - DOOMSDAYDATE
DOOMSDAY <-(d +diff +ANCHORDAY) mod 7
Ensure DOOMSDAY is in the range 0-6
7. Write a method to convert the Doomsday number to a string
8. Write a driver class to capture the year, month & day via a Scanner instance and
demonstrate the Doomsday class’ functionality.

THIS IS HOW I STARTED IT i DON'T KNOW TO PROCEED
public class Doomsday {
public static final int Monday = 0;
public static final int Tuesday = 1;
public static final int Wednesday= 2;
public static final int Thursday = 3;
public static final int Friday = 4;
public static final int Saturday = 5;
public static final int Sunday = 6;

public int Year(){}
public int Month() {} // the private memebers
public int Day() {}

public int getAnchorDay()

for (day;day==1800-1899;day++){
return Friday;
}
for (day;day==1900-1999;day++){
return Wednasday;
}
for (day;day==2000-2099;day++){
return Tuesday;
}
for (day;day==2100-2199;day++){
return Sunday;
}
publlic getDoomsdayDate()
Jan – 3 (or 4 if leap year), Feb – 28 (or 29 if leap year)
March – 0 (last day in February), April – 4, May – 9, June - 6
July – 11, August – 8, September – 5, October – 10, November - 7
December – 12
I dont know how to do this one ?
public getDoomsday()
I din't know how to do this one ?

Reply With Quote
Reply

Viewing: ASP Free ForumsOtherProgramming Help > Creating a days ,month and year ranges and leap year


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway