1. Engineering
  2. Computer Science
  3. implementing a gregorian date class...

Question: implementing a gregorian date class...

Question details

Implementing a Gregorian Date Class

ANT OF CSC 1351-03,04, Spring 2019, Lab 1 Name this project Date Implementing a Gregorian Date Class Implomont a basic Date class whose objocts represent dates on the Gregorian oxcoption handling capability. Also, writo a toster class, DateDemo, that creates Date object using the constructors, modifios them and prints them out in the day-of the-week month-name day, year format using the print statement The Date Class The Date class should have month, day and year, all integers, as the tields of a Date object The class should include the following constructors Datol)creates January 1, 197o. Dateint m, int d, int y): creates a Date object using the specified parameters, where m represents the month, d, the day, and y, the year : Date Date dlate); creates anobject of the Date class equivalent to the specified date object. The Date class should have the following instance (accessor and mutator) methods: int getMonth): returns the month in an object of the Date class. irst getDay): returns the day in an object of the Date class. int get Year): retuns the year in an in object of the Date class . void setDate(int m, int d, int y), modifies a Date object using the specified parameters, wftere m represents the month, d, the day, and y, the year The DateDemo Class Write a program, DateDemo, that does the following 1. Prompts the user for the first day of class. 2. Reads a string in the format mmdd yyyy, parses the string into three integers representing the month, day and year, and uses the parameterized constructor to create a Date object using the three values 3. Using the copy constructor, creates a second Date object that represents the last day of dass. Use the tirst day of cass as an explicit parameter to the constructor. 4. Using appropriate accessor methods, prints the first day of class in day-of-the-week, month-name day year formatFOR 5. Using appropriate accessor mothods, prints the tast day of class in day of-the weok moneh NO LD name day year format d Usihg the mutator, moditios last day of class using aspropriate parameters 7 Again , prints both the first and last day of class in day-of the-week month-name day, year format using appropriate accessor methods In order to detormine the weekday on which a day falls, use the following algorithm: -23-(tery eal 4), where century is tho first two digts of the year. For example sontaru is 20 for the year 2011 rthe last two digits of the year. For example, Is 11 for 2011 a- using intoger division. For xample 11/4 2 tor 2011. 4 s determined using the month Table 1. For example, Is 3 for February 2011, Month x 0 (6 in a leap year) 2 312n a loap year 4 e 10 0 12 5 Table 1: Month There are two ways in which a year may be a leap year DEFİNITİON 1. Ary year that is either a multiple of 400 or is not a multiple of 100,but is a multiple of 4 is a leap year 5.,.. + .r + day, V#6+11 +2+3+3 25for February 3, 2011. 6 day al the week- md 7. For example, February 3, 2011 occurs on Thursday. since 25 mod 7 is 4 Note that 0 Sunday. 1- Monday.....6 Saturday Implement a method, static String lindWeekDay(int month, int day, int year), in the main class, DateDemo, that retuns the weekday for a given date using the algorithm described above. Your main dlass will consist of two methods: this method and the main.

Read the Java online API documentation for the spilit method in the String class and the In- me thod in the Integer class. They may be handy when dealing with Inputs. Additional Requirements must be public and allinstance varlables private. Do not use if-statements to deter- ays of strings, one with the names ot the mine the name of the weekday or month: declare two arr months and the other with the days of the weok, and use the appropriate Indexes to when needed Avold any other unnecessary us of i-statements. Exhaustively, test your program to ensure that it works. (You may find the calendar generator at http:/www.dayoftheweek.org heiptul Iin verifying the correctness of your program.) Do not test your program using an invalid date or a date before 1583 Here are two sample program interactions: 1: Sample Run 1 1 Enter the first day of class8/22/2016 3 First day of class: Monday, August 22, 2016 4 Last day of class: Monday. August 22. 2016 6 Enter the last day of class 12/8/2016 8 First day of class: Monday, August 22, 2016 9 Last day of class: Thursday, December 8, 2016 Listing 2: Sample Run 2. 1 Enter the first day of class 2/7/1900 3 First day of class: Wednesday. February 7. 1900 4 Last day of class: Wednesday. February 7, 1900 6 Enter the last day of class /19/1901 8 First day of class: Wednesday. February 7, 1900 9 Last day of class: Saturday, January 19, 1901

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution