computer science

posted by .

How would you write this program?

We are using Java in Netbeans IDE..

Write a program to enter the year (ex 2004) and month number (1-12) then compute the number of days in that month.

Example
Enter the Year: 2004
Enter the Month: 2
There are 29 days in that month

  • computer science -

    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

  • computer science -

    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

Respond to this Question

First Name
School Subject
Your Answer

Similar Questions

  1. computer science /use java language

    write the program that inputs a string representing a binary number(0s and 1s). First, your program should veerify that it is indeed a binary number, that is, the number contains only 0s and 1s . if that is not the case, your program …
  2. computer science

    I need help with my Java homework! Write a program that calculates a customer's monthly bill. It should ask the user to enter the letter of the package the customer has purchased (A, B, or C) and the number of hours that were used. …
  3. Computer Science

    We are using Netbeans IDE for my class and i have no clue on how to write this program... Write a program to enter a score and a points possible for a test, computer the percent, display the percent to 1 decimal place and then display …
  4. statistics

    a company decides to add a new program that prepares randomly selected sales personnel to increase their number of sales per month. The mean number of sales per month for the overall popualtion of sales people at this national company …
  5. Psychology

    1. A company decides to add a new program that prepares randomly selected sales personnel to increase their number of sales per month. The mean number of sales per month for the overall population of sales people at this national company …
  6. Statistics

    1. A company decides to add a new program that prepares randomly selected sales personnel to increase their number of sales per month. The mean number of sales per month for the overall population of sales people at this national company …
  7. programming

    Temp Employer wants a program that will allow the company’s clerk to enter an employee’s name and the number of hours the employee works every month. (The number of hours worked will always be an integer). The program will display …
  8. computer science

    In the Meteorological institute at Ruritania, one can find the following at Shiaho Railway Station in 2013 • In May 22 days with rainfall totaled 89 mm in that month • In June 1822 days with rainfall totaled 127 mm in that month …
  9. java programming

    Your boss at Ruritania Weather Center (RWC) has asked you to write a small program for center. The specification are as follows: a. the program asks a user to enter a number between 1 and 12 inclusive representing the months January …
  10. intro to computer programming

    I need help with my Java homework! Write a program that calculates a customer's monthly bill. It should ask the user via dialog box to enter the letter of the package the customer has purchased (A, B, or C) and the number of hours …

More Similar Questions