Computer Science 202
Introduction to Programming

Fall 2012, The College of Saint Rose

Lab 4: Days in Month
Due: 11:59 PM, Tuesday, October 2, 2012

In this lab, you will write a program to calculate the number of days in a given month in a given year.

You may work alone or with a partner on this lab.

Days Per Month

In case you don't remember, here are the numbers of days per month in the modern calendar:

Month

Days
January 31
February 28 or 29
March 31
April 30
May 31
June 30
July 31
August 31
September 30
October 31
November 30
December 31

February has 28 days except during a leap year. A leap year occurs in any year divisible 4 (with some exceptions we will not worry about for the purposes of this assignment). This simple rule works for years 1901 through 2099.

Your program will read in two integers, a month number (1 for January, 2 for February, etc.) and a year number. It will output the number of days in that month with a message like:

There are 30 days in 9/2012.

Getting Set Up

Lab Procedure

Write a Java program in a class called DaysInMonth that solves the above problem. You are encouraged to develop a Visual Logic flowchart first, but you need not turn that in. For your Java program, you may use either terminal I/O with a Scanner and System.out.println calls or dialog boxes with JOptionPanes.

Here are some guidelines and suggestions for your program:

Bonus points if your program reads in months by name instead of by number.

Style and Documentation Reminders

Before you submit your programs, make sure they conform to our guidelines for style and documentation.

In particular, you should have a comment at the top of each class that describes your program and has your name (and that of your partner if you are working with someone), the course number and section (02 for 11:15, E1 for 4:10). You should have comments throughout your programs describing your variables and any non-obvious Java statements or groups of statements.

All identifiers (class names and variable names) should be meaningful and conform to Java's naming conventions.

Your code should be nicely formatted, with new lines after any { or }, and indented as done in class examples.

Submitting Your Work

Before 11:59 PM, Tuesday, October 2, 2012, submit your Java program to Blackboard for grading. Please upload only your Java source file DaysInMonth.java - the one with the .java file extension, not the .class, .ctxt, package.bluej or README files).

Grading

This assignment is worth 30 points, which are distributed as follows:

> FeatureValueScore
Reading inputs 4
Error checking inputs 4
Computing basic days per month 5
Leap year correctness 4
Appropriate output 3
Using correct filename 1
Comments 4
Naming conventions 3
Formatting 2
Bonus for month names instead of numbers 2
Total 30