Java程序辅导

C C++ Java Python Processing编程在线培训 程序编写 软件开发 视频讲解

客服在线QQ:2653320439 微信:ittutor Email:itutor@qq.com
wx: cjtutor
QQ: 2653320439
Fourth Java Assignment: Calendar Fourth Java Assignment: Calendar CIT 591, David Matuszek, Fall 2001 So far, your assignments have each involved a lot of new ideas. Much of programming is just "bookkeeping"--keeping track of things. The purpose of this assignment is not to introduce a bunch of new ideas, but rather to give you some additional practice in handling the routine chores. Almost no use is made of class and object concepts. In this assignment, given a year (such as 2001), you will write an application to print out a 12-month calendar for the year. Your calendar should look something like this: January 2001 S M Tu W Th F S 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 February 2001 S M Tu W Th F S 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 ...and so on. Some of the things you need to do are: Figure out what day of the week the year begins Loop through all 12 months, and for each month: Print the name of the month Print a line giving the days of the week (put Sunday first) Figure out how many days are in the month Print one line of numbers for each week in the month Figure out what day of the week the next month begins on (This list probably isn't complete.) Like I said, a lot of bookkeeping. An important principle in designing methods is that each method should do one simple, easily defined thing, rather than a potpourri of things. In this program, you are to write one or more additional methods (besides main). I can easily think of three separate things that each need to be done twelve times; these could be three separate methods, or combined into two or one methods. I can think of another thing that needs to be done approximately 365 times; perhaps this should be a method. Methods should be chosen and named in such a way as to make the program easier to read. By the way, this program makes almost no use of objects. Your methods should probably all be static. You do need to use a few new things. You probably already know that an application requires at least this method: public static void main(String args[]) When you run your application, in the BlueJ dialog box that pops up, enter a year number as a string (that is, quoted) within the braces. Like this: To retrieve this value, use: int year; year = Integer.valueOf(args[0]).intValue(); You also need to figure out on which day of the week the year begins. This is extremely complicated; let Java do it for you. You should have the Java API documentation on your hard drive in some location resembling C:\jdk1.3.1\docs\api\index.html; open it. (If not, find it on the web at http://java.sun.com/j2se/1.3/docs/api/index.html.) Under All Classes, look up the Calendar package. You'll find a possibly interesting discussion of the complexities of the package, but somewhere below that you'll find what you want. (Hint: Create a Calendar, set a date, look at a variable.)