School Assignment? Project Due Tomorrow? Chat LIVE With A Programming Expert!
Welcome to Dream.In.Code
Become an Expert!

Join 340,165 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 3,960 people online right now. Registration is fast and FREE... Join Now!



Calendar program

Calendar program Can you help me please? Rate Topic: -----

#1 drilli  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 26-May 09


Dream Kudos: 0

Post icon  Posted 26 May 2009 - 03:41 AM

Design a calendar program, which takes two inputs: a month (an integer
in range 1..12) and a year (for simplicity, we require an integer of 1900
or larger) and presents as its output the calendar for the month and year
speciŻed. We might use the program to see the calendar for December,
2010:

Su Mo Tu We Th Fr Sa
1 2 3 4
5 6 7 8 9 10 11
12 13 14 15 16 17 18
19 20 21 22 23 24 25
26 27 28 29 30 31

The application's model will need methods to calculate how many days are
in a given month (within a given year), on what day of the week a given
month, year begins, whether a year is a leap year, etc.


(B) Next, revise the application so that, on demand, the calendar prints a
proper French calendar, that is, the days are presented Monday-Tuesday-
...-Sunday (lundi-mardi-mercredi-jeudi-vendredi-dimanche) with the labels,
lu ma me je ve sa di
Was This Post Helpful? 0
  • +
  • -


#2 blackstarzes  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: New Members
  • Posts: 2
  • Joined: 25-May 09


Dream Kudos: 0

Posted 26 May 2009 - 03:50 AM

Take a look at java.util.Calendar.

If you're not allowed to use that class, you need a static point in time that will give you something to work from (try the epoch - 1 January 1970). Then if you take a look at how the roll() methods work in java.util.Calendar and try to duplicate them in your own class, you might have some luck.
Was This Post Helpful? 0
  • +
  • -

#3 rishabhsharma  Icon User is offline

  • D.I.C Head
  • Icon
  • View blog
  • Group: Contributor w/DIC++
  • Posts: 202
  • Joined: 26-March 09


Dream Kudos: 500

Posted 26 May 2009 - 07:04 AM

Since it is your first post therefore I am willing to give you source code but from hitherto don't dare to ask free codes, if you want correct codes then firstly show some effort and then we will try to amend your program.

Check out this ............

http://www.dreaminco...snippet3422.htm

and also


import java.util.*;
public class CalendarDemo
	{
		public static void CalendarDemo(int Year,int Month,int Date)
			{
				GregorianCalendar a = new GregorianCalendar();
				a.set(Calendar.YEAR,Year);
				a.set(Calendar.MONTH,(Month-1));
				a.set(Calendar.DAY_OF_MONTH,1);
				int weekday = a.get(Calendar.DAY_OF_WEEK);
				int month = a.get(Calendar.MONTH);
				System.out.println("'\n'	  YEAR : "+Year);
				switch(month)
					{
						case 0:
						System.out.println();
						System.out.println("		JANUARY			");
						System.out.println();
						break;
						case 1:
						System.out.println();
						System.out.println("		FEBRUARY		   ");
						System.out.println();
						break;
						case 2:
						System.out.println();
						System.out.println("		 MARCH			");
						System.out.println();
						break;
						case 3:
						System.out.println();
						System.out.println("		 APRIL		   ");
						System.out.println();
						break;
						case 4:
						System.out.println();
						System.out.println("		  MAY			");
						System.out.println();
						break;
						case 5:
						System.out.println();
						System.out.println("		  JUNE		  ");
						System.out.println();
						break;
						case 6:
						System.out.println();
						System.out.println("		  JULY			");
						System.out.println();
						break;
						case 7:
						System.out.println();
						System.out.println("		 AUGUST		   ");
						System.out.println();
						break;
						case 8:
						System.out.println();
						System.out.println("	   SEPTEMBER			");
						System.out.println();
						break;
						case 9:
						System.out.println();
						System.out.println("		OCTOBER		   ");
						System.out.println();
						break;
						case 10:
						System.out.println();
						System.out.println("		NOVEMBER			");
						System.out.println();
						break;
						case 11:
						System.out.println();
						System.out.println("		DECEMBER		   ");
						System.out.println();
						break;
				  }
			   System.out.println("Sun Mon Tue Wed Thu Fri Sat");
			   for(int i=Calendar.SUNDAY;i<weekday;i++)
				{
					System.out.print("	");
				}
			   do
					{
						int day = a.get(Calendar.DAY_OF_MONTH);
						if(day<10)
							{
								System.out.print(" "+day);
							}
						else if(day>=10)
							{
								System.out.print(day);
							}
						if(day==Date)
							{
								System.out.print("* ");
							}
						else
							{
								System.out.print("  ");
							}
						if(weekday==Calendar.SATURDAY)
							{
								System.out.println();
							}
						a.add(Calendar.DAY_OF_MONTH,1);
						weekday = a.get(Calendar.DAY_OF_WEEK);
					}
				while(a.get(Calendar.MONTH)==month);
				if(weekday != Calendar.SUNDAY)
				{
				System.out.println();
				}
				System.out.println();
				System.out.println("Note: '*' over any number is your desired number");
			}
		}
							   


Was This Post Helpful? 0
  • +
  • -

#4 drilli  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 26-May 09


Dream Kudos: 0

Posted 26 May 2009 - 08:08 AM

Thank you very much rishabhsharma.Now it is all ok with that code

This post has been edited by drilli: 27 May 2009 - 06:14 AM

Was This Post Helpful? 0
  • +
  • -

#5 NeoTifa  Icon User is offline

  • 1-800-NEO-ROXS
  • Icon
  • View blog
  • Group: Authors
  • Posts: 7,603
  • Joined: 24-September 08


Dream Kudos: 150

Posted 26 May 2009 - 08:48 AM

Why don't you post the code you have?
Was This Post Helpful? 0
  • +
  • -

#6 drilli  Icon User is offline

  • New D.I.C Head
  • Pip
  • Group: Members
  • Posts: 13
  • Joined: 26-May 09


Dream Kudos: 0

Posted 26 May 2009 - 09:38 AM

Thank you very much rishabhsharma.Now it is all ok with that code

This post has been edited by drilli: 27 May 2009 - 06:11 AM

Was This Post Helpful? 0
  • +
  • -



Fast Reply

  

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users



Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month