Sunday, October 21, 2012

leap year


/**
 * A program to tell whether an year is leap year or not.
 * @author Umang Bhatt
 */
public class LeapYearTester
{

        public static boolean isLeapYear(int year)
        {
                boolean isLeapYear ;
                if (year % 4 == 0)
                {
                        if (year % 100 == 0)
                        {
                                if (year % 400 == 0)
                                {
                                        isLeapYear = true;
                                }
                                else
                                {
                                        isLeapYear = false;
                                }
                        }
                        else
                        {
                                isLeapYear = true;
                        }
                }
                else
                {
                        isLeapYear = false;
                }
                return isLeapYear;
        }

        public static void main(String args[])
        {
                System.out.println(isLeapYear(2003));
        }
}

2 comments:

  1. i want to
    Description:
    The script should display the following menu and perform according to the choice of the user. The description of the required functionality of each option is included below.
    -------------------------------------------------------------------
    Welcome to general administration script.
    1. Create a new user.
    2. Backup a partition.
    3. Schedule this script using cron.
    4. Change to a different runlevel.
    5. Quit.
    --------------------------------------------------------------------
    Description of the options:
    1. Create a new user. Ask for the username, full name, and password. Then use this information to create a new user in the system. (Hint: use the default values for home directory location and default shell.)
    2. Backup an entire partition. Ask for the partition name (directory associated with that partition) and the target location to save the backup file. Then make a copy of that directory in the desired location as a single archive file, with current date as the file extension. (Hint: use the dump backup utility for help.)
    3. Schedule this script to run at the user’s requested schedule using cron service. For this purpose, ask the user for all the information necessary to make a schedule with crontab command and then set the schedule as requested. (Hint: ask for minute, hour, day, month, and day of the week)
    4. Change to a different runlevel. Ask the new runlevel number (0-6) from the user and change to that runlevel with appropriate commands.
    5. Quit. Exit the program with this choice.

    ReplyDelete
    Replies
    1. is it with windows ? would this help you with administration ?

      Delete