By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,736 Members | 1,982 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,736 IT Pros & Developers. It's quick & easy.

Serious Help...need It By Thursday

P: 37
hey i really need help...i got this code....basically im suppose to make a calender that allows a user to type in month and year .... and the calander displays it on the scree using "GregorianCalendar"....and finally the users shold be able to select a date and store information...

please feel free to edit the code and play around with it...if you do please commen them out so i understand it...

peace...


P.S. IT CANT BE ON APLET

THE CODE I DID...
import java.util.*;
import java.text.*;

public class CalendarManager {

/** List names of the month */
String months[] = { "January" , "February" , "March", "April" , "May" ,
"June","July" , "August" , "September", "October" , "November" , "December"};

/** List the days in each month and assigining them to the month*/
int DaysOfMonths[] = {31, 28, 31,30, 31, 30,31, 31, 30,31, 30, 31};



public void printMonth(int mm, int yy) {
// The number of days to leave blank at
// the start of the month.
int BlankSpaces = 5;
// here it prints the month and year
// on top to show what month an year it is
System.out.println(" " + months[mm] + " " + yy);

if (mm < 0 || mm > 11) {
throw new IllegalArgumentException(
"Month " + mm + " bad, must be 0-11");
}
GregorianCalendar cal = new GregorianCalendar(yy, mm, 1);
System.out.println("Su Mo Tu We Th Fr Sa");

// work out how much to leave before before the first day of the month.
// getDay() returns 0 for Sunday.
BlankSpaces = cal.get(Calendar.DAY_OF_WEEK)-1;


int daysInMonth = DaysOfMonths[mm];

if (cal.isLeapYear(cal.get(Calendar.YEAR)) && mm == 1) {
++daysInMonth;
}


// Leave black spaces before 1st of every month
for (int i = 0; i < BlankSpaces; i++) {
System.out.print(" ");
}
for (int i = 1; i <= daysInMonth; i++) {

if (i<=9) {
System.out.print(" ");
}
System.out.print(i);
if ((BlankSpaces + i) % 7 == 0) {
System.out.println();
} else {
System.out.print(" ");
}
}
System.out.println();
}




public static void main(String[] args) {
//int month, year;
CalendarManager MonthView = new CalendarManager(); // new name given for CalendarManager
// display message to give instructions
Scanner UserInput = new Scanner (System.in); // new keyboard scanner created
System.out.println("Please type in month: "); // ask for input

// this is when the data typed in keyboard is assigned to UserInput
String TypedMonth = UserInput.nextLine(); // take input
System.out.println("You typed in " + TypedMonth + " to display.");

System.out.println(); // print free line

//if (TypedMonth == months); // does not work
Calendar today = Calendar.getInstance();
MonthView.printMonth(today.get(Calendar.MONTH), today.get(Calendar.YEAR));

}

}
THE ASSIGNMENT FOR MORE DETAIL......
Implement classes DisplayManager (abstract class), CalendarManager. CalendarManager displays in text format one month at a time. The CalendarManager class should provide a method which displays a text menu, giving the user the capability of selecting the calendar of a month for a specific year to display. For example, when the user enters October and 2005, the following should be displayed:

October 2005
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

To find out, the day of the week for a specific date, you might find useful the GregorianCalendar
class (and its related classes), located in the Java library package java.util. The displayed text menu, should also give the user the possibility to store information (in terms of a long string) for an appointment set at some specific date (day, month and year). For example, by selecting option c (create appointment), the user should be prompted for a day, month and year to set an appointment. Following that, the user should be asked for the appointment’s description (e.g. Meeting with supervisor to discuss project progress). The menu should also give the user the capability of retrieving all the information about appointments on a specific date. Implement a test class which creates instances of all the implemented classes and tests their functionality.
Dec 6 '06 #1
Share this Question
Share on Google+
1 Reply


P: 1
hey i really need help...i got this code....basically im suppose to make a calender that allows a user to type in month and year .... and the calander displays it on the scree using "GregorianCalendar"....and finally the users shold be able to select a date and store information...

please feel free to edit the code and play around with it...if you do please commen them out so i understand it...

peace...


P.S. IT CANT BE ON APLET

THE CODE I DID...


THE ASSIGNMENT FOR MORE DETAIL......
Implement classes DisplayManager (abstract class), CalendarManager. CalendarManager displays in text format one month at a time. The CalendarManager class should provide a method which displays a text menu, giving the user the capability of selecting the calendar of a month for a specific year to display. For example, when the user enters October and 2005, the following should be displayed:

October 2005
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

To find out, the day of the week for a specific date, you might find useful the GregorianCalendar
class (and its related classes), located in the Java library package java.util. The displayed text menu, should also give the user the possibility to store information (in terms of a long string) for an appointment set at some specific date (day, month and year). For example, by selecting option c (create appointment), the user should be prompted for a day, month and year to set an appointment. Following that, the user should be asked for the appointment’s description (e.g. Meeting with supervisor to discuss project progress). The menu should also give the user the capability of retrieving all the information about appointments on a specific date. Implement a test class which creates instances of all the implemented classes and tests their functionality.


hey is this the full code for the program u create cos i am doin the same thing can u help me
Nov 27 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.