Question: Q1. In this question, you are asked to write a program that will perform the tasks listed below. - (10 pts.) Write a java class

Q1. In this question, you are asked to write a program that will perform the tasks listed below. - (10 pts.) Write a java class Date that has integer class variables year, month and day with private visibilities. - ( 10 pts:) Define a constructor method that sets up an Date object with given numbers of year, month and day. - (5 pts.) Write methods getYears, getMonth and getDay that return year, month and day values respectively. - (5 pts.) Write a method set Year that sets up a year value. - ( 15 pts.) Write a method setMonth that sets up a month value. The month value should be between 1 and 12 , otherwise the method should print "Invalid month" on the screen. - (15 pts.) Write a method setDay that sets up a day value. The day value should be between 1 and 31 , otherwise the method should print "Invalid day" on the screen. - (10 pts.) Write a method printDate that returns the date as string in "day. month.year" format. - (10 pts.) Write a method OddEvenYear that checks whether the year value is even or odd, and returns the character ' E ' if the year value is even, and ' O ' otherwise. - (5 pts.) Write a Test class, and in the main, create a Date object with 2022 as the year, 12 as the month, and 27 as the day. - (5 pts.) Set up month and day values as 14 and 25. - (5 pts.) Print the date by calling printDate method. - (5 pts.) Call the OddEven Year method and print the result
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
