Posted by Anonymous on Sunday, October 17, 2010 at 11:51pm.
Some of the following links may help you:
http://search.yahoo.com/search?fr=mcafee&p=how+to+write+programs+with+Java+in+Netbeans+IDE
Sra
You have to do two things:
1. create an array of 12 elements, each of which represents the number of days in the month of a non-leap year. So when the month is given, you can look up the array to give the answer.
2. To take care of leap years, you need to create a boolean function (public boolean isLeapYear(int year){} ) taking the year as an argument, and return true if it is a leap year, and false otherwise.
The rule for leap years as of the Gregorian calendar (see link) in 1582 is as follows:
"Years divisible by 4 are leap years, except for years divisible by 100, which are non-leap years,
except for years divisible by 400, which are again leap years."
To check your implementation, check that 1900 was NOT a leap year, and 2000 WAS a leap year.
If the entered month is 2 (February), then you code need to check for leap year. If isLeapYear(year) returns true, display 29 days, otherwise, display 28 days.
Link for history of Gregorian calendar:
http://en.wikipedia.org/wiki/Gregorian_calendar
Related Questions
Computer Science - We are using Netbeans IDE for my class and i have no clue on ...
programming - Having troube with java, i am not a regular programmer, if anybody...
Video in java(netbeans) - Hi, i am using netbeans and i'm trying to ...
Computer Science - Design a program that will ask the user to enter the amount ...
Java - Can anybody help me figure how to post a Java file to as an attachment. I...
computer science - I need to write a program that ask the student to enter an ...
Programming - Write a pseudocode program that asks the user for an integer ...
computer - Create a new project Lab05e, and write a program that asks the user ...
java - can anyone help me with this? I'm new to java! Write a program that ...
programming - I am having trouble writing this program for java. can anybody ...
For Further Reading