Question: Below is the TeacherDate.class ; a java/lang/Object ()V java/util/Scanner java/lang/System in Ljava/io/InputStream; (Ljava/io/InputStream;)V out Ljava/io/PrintStream; )What month, day, and year were you born? java/io/PrintStream print

 Below is the TeacherDate.class ; a java/lang/Object ()V java/util/Scanner java/lang/System inLjava/io/InputStream; (Ljava/io/InputStream;)V out Ljava/io/PrintStream; )What month, day, and year were you born?java/io/PrintStream print (Ljava/lang/String;)V ! nextInt ()I # TeacherDate " % & (III)V

Below is the TeacherDate.class

; a java/lang/Object ()V java/util/Scanner java/lang/System in Ljava/io/InputStream; (Ljava/io/InputStream;)V out Ljava/io/PrintStream; )What month, day, and year were you born? java/io/PrintStream print (Ljava/lang/String;)V ! nextInt ()I # TeacherDate " % & (III)V " ( ) * toString ()Ljava/lang/String; " , - * getDayOfWeek / 0 1 makeConcatWithConstants 8(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String; 3 4 println " 6 7 8 isLeapYear ()Z " : ; ! getYear = 0 > (I)Ljava/lang/String; " @ A ! getDay = D Birthday Code LineNumberTable main ([Ljava/lang/String;)V StackMapTable K [Ljava/lang/String; SourceFile Birthday.java BootstrapMethods P Q R S 0 T $java/lang/invoke/StringConcatFactory (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite; V !You were born on , which was a X was a leap year Z "It will be your birthday in days. InnerClasses ] %java/lang/invoke/MethodHandles$Lookup _ java/lang/invoke/MethodHandles Lookup ! C E * F G H E Y L + =+ >+ 6 "Y $: ' + . 2 5 9 # 0 E N ^ a n q w I ^ J " L M N O U O W O Y [ \ ^ `

Problem 2 Turn in three Java classes named Birthday, Date, TestDate stored in files named Birthday.java, Date.java, and TestDate.java respectively. You will also need the support file TeacherDate.class (provided but you have to place this file in the same folder as your program). The problem has two parts: a program that uses teacherdate objects to print information about the user's birthday, and a Date class of your own whose objects represent calendar dates (with its tester Test Date). Part A (Birthday program): The first part of this problem asks you to write a Java program that uses the provided date class (Teacher Date.class). Your program should prompt the user for his/her birth year, month, and day. Based on this information, you will print that birth date, what day of the week it fell on, a message if that was a leap year, and the number of days until the user's birthday. If it is the user's birthday, you will print a Happy Birthday message including the user's current age. The following three logs of execution show the various behaviors of the program. Note that the number of days until the user's birthday depends on when the program was run. The logs of execution below were generated on Sunday, February 28, 2021. If you run the program on a different date, you will receive slightly different output. Example logs of execution (user input underlined): what month, day, and year were you born? 5 5 2008 You were born on 2008/5/5, which was a Monday. 2008 was a leap year. It will be your birthday in 66 days. You are 4682 days old. What month, day, and year were you born? 8 11 2004 You were born on 2004/8/11, which was a Wednesday. 2004 was a leap year. It will be your birthday in 164 days. You are 6045 days old. what month, day, and year were you born? 11 21 1978 You were born on 1978/11/21, which was a Tuesday. It will be your birthday in 266 days. You are 15440 days old. What month, day, and year were you born? 2 28 1970 You were born on 1970/2/28, which was a Saturday. Happy birthday! You are now age 51. You are 18628 days old. You should implement this program using the expected behavior of Teacher Date objects (TeacherDate.class is provided). A Teacher Date methods and behavior are described below. You can construct a Teacher Date object in one of two ways: TeacherDate date - new TeacherDate (year, month, day); // represents specific date Teacher Date today - new Teacher Date(); // represents today You may assume that the user types valid input: the user will type integers, and they will be within the proper ranges (year will be at least 1753, month will be between 1 and 12, and day will be between 1 and the number of days in that month, and that the user's birthdate will be a date no later than today (the user will not claim to have been born in the future)). You may also assume that the user's birthday is not on the "leap day" of February 29, because this is an odd case, since that date only occurs approximately once every four years. (Leap day babies usually celebrate their birthdays on February 28 or March 1 on non-leap years.) Methods that are present in the TeacherDate class and you can use: public TeacherDate (int year, int month, int day) Constructs a new TeacherDate representing the given year, month, and day. You may assume that the parameter values are valid. Since the modern Gregorian calendar was established in late 1752, you may assume that the year parameter value will be greater than or equal to 1753. public TeacherDate() Constructs a new Teacher Date representing today (the date at which the program is run). 2 of 6 public int getDay() Returns this Teacher Date's day of the month, between 1 and the number of days in that month (which will be between 28 and 31). public int getMonth() Returns this Teacher Date's month of the year, between 1 and 12. public int getYear() Returns this Teacher Date's year. public String getDayOfWeek () Returns a String representing what day of the week this TeacherDate falls on. The String will be either "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", or "Saturday". (1753/1/1 was a Monday) public boolean isLeapYear() Returns whether this Teacher Date's year is a leap year. Leap years are all years that are divisible by 4, except for years that are divisible by 100 but not by 400. For example, 1756, 1952, 2004, 1600, and 2000 are all leap years, but 1753,2005, 1700, and 1900 are not public void nextDay() Advances this Teacher Date to the next day after its current day. Note that this might advance the Teacher Date into the next month or year. For example, the next day after August 7 is August 8; the next day after December 31 is January 1; the next day after February 28, 2005 is March 1, 2005, and the next day after February 28, 2004 is February 29, 2004 (because 2004 is a leap year). public String toString() Returns a String representation of this Teacher Date, in a year/month/day format to match the following: "2005/5/24" Part B (Date class and TestDate): The second part of this problem asks you to implement a class named Date. Your Date class should implement the following behavior. None of the methods below should print any output to the console. You may not call any methods or utilize any behavior from the TeacherDate class to help implement your Date class (other than getDaysSinceEpoch, see below), nor use any of Java's date-related objects such as GregorianCalendar. Methods you must implement in your Date class: public Date(int year, int month, int day) Constructs a new Date representing the given year, month, and day. You may assume that the parameter values are valid. Since the modern Gregorian calendar was established in late 1752, you may assume that the year parameter value will be greater than or equal to 1753. public Date() Constructs a new Date representing today (the date at which the program is run). It may be helpful for you to know that the following expression returns the number of days that have elapsed since January 1, 1970. (You must import java.util.*; to be able to refer to Time Zone.) int daysSinceEpoch = (int) ((System.currentTimeMillis() + TimeZone.getDefault().getRawoffset()) / 1000 / 60 / 60 / 24); public int getDay() Returns this Date's day of the month, between 1 and the number of days in that month (which will be between 28 and 31). public int getMonth() Returns this Date's month of the year, between 1 and 12. public int getYear() Returns this Date's year. public String getDayOfWeek () Returns a String representing what day of the week this Date falls on. The String will be either "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", or "Saturday". For example, August 7, 2005 fell on a Sunday, so the 3 of 6 return value for a new Date (2005, 8, 7) object would be "Sunday". It may be helpful for you to know that January 1, 1753 was a Monday public boolean isLeap Year() Returns whether this Date's year is a leap year. Leap years are all years that are divisible by 4, except for years that are divisible by 100 but not by 400. For example, 1756, 1952, 2004, 1600, and 2000 are all leap years, but 1753, 2005, 1700, and 1900 are not. public void next Day() Advances this Date to the next day after its current day. Note that this might advance the Date into the next month or year. For example, the next day after August 7 is August 8; the next day after December 31 is January 1; the next day after February 28, 2005 is March 1, 2005, and the next day after February 28, 2004 is February 29, 2004 (because 2004 is a leap year). public String toString() Returns a String representation of this Date, in a year/month/day format to match the following: "2005/5/24" Hints: Complete Part A before Part B, to get a good understanding of how Date objects work. Write Part B in phases: Write the Date (year, month, day) constructor, getDay, getMonth, getYear, toString methods first. Then implement isLeapYear. Next, try to write nextDay. (You may wish to write a helping method that returns the number of days in this Date's month, to help you implement nextDay.) Lastly, write getDayOfWeek and the Date () 'today' constructor. You can use your nextDay method to help you write these methods. You can test your Date class by creating TestDate, a modified version of your Part A Birthday program that uses your Date instead of Teacher Date. Avoid redundancy and break down the overall problem into methods that each solve part of the overall problem. Your main method should still contain the overall control flow of the program. In Part B, in your Date class, you should use some global constants (Finals) in your program, to avoid "magic numbers." The choice of what constant to use is up to you, but it should represent an important value that is used in your class. . Problem 2 Turn in three Java classes named Birthday, Date, TestDate stored in files named Birthday.java, Date.java, and TestDate.java respectively. You will also need the support file TeacherDate.class (provided but you have to place this file in the same folder as your program). The problem has two parts: a program that uses teacherdate objects to print information about the user's birthday, and a Date class of your own whose objects represent calendar dates (with its tester Test Date). Part A (Birthday program): The first part of this problem asks you to write a Java program that uses the provided date class (Teacher Date.class). Your program should prompt the user for his/her birth year, month, and day. Based on this information, you will print that birth date, what day of the week it fell on, a message if that was a leap year, and the number of days until the user's birthday. If it is the user's birthday, you will print a Happy Birthday message including the user's current age. The following three logs of execution show the various behaviors of the program. Note that the number of days until the user's birthday depends on when the program was run. The logs of execution below were generated on Sunday, February 28, 2021. If you run the program on a different date, you will receive slightly different output. Example logs of execution (user input underlined): what month, day, and year were you born? 5 5 2008 You were born on 2008/5/5, which was a Monday. 2008 was a leap year. It will be your birthday in 66 days. You are 4682 days old. What month, day, and year were you born? 8 11 2004 You were born on 2004/8/11, which was a Wednesday. 2004 was a leap year. It will be your birthday in 164 days. You are 6045 days old. what month, day, and year were you born? 11 21 1978 You were born on 1978/11/21, which was a Tuesday. It will be your birthday in 266 days. You are 15440 days old. What month, day, and year were you born? 2 28 1970 You were born on 1970/2/28, which was a Saturday. Happy birthday! You are now age 51. You are 18628 days old. You should implement this program using the expected behavior of Teacher Date objects (TeacherDate.class is provided). A Teacher Date methods and behavior are described below. You can construct a Teacher Date object in one of two ways: TeacherDate date - new TeacherDate (year, month, day); // represents specific date Teacher Date today - new Teacher Date(); // represents today You may assume that the user types valid input: the user will type integers, and they will be within the proper ranges (year will be at least 1753, month will be between 1 and 12, and day will be between 1 and the number of days in that month, and that the user's birthdate will be a date no later than today (the user will not claim to have been born in the future)). You may also assume that the user's birthday is not on the "leap day" of February 29, because this is an odd case, since that date only occurs approximately once every four years. (Leap day babies usually celebrate their birthdays on February 28 or March 1 on non-leap years.) Methods that are present in the TeacherDate class and you can use: public TeacherDate (int year, int month, int day) Constructs a new TeacherDate representing the given year, month, and day. You may assume that the parameter values are valid. Since the modern Gregorian calendar was established in late 1752, you may assume that the year parameter value will be greater than or equal to 1753. public TeacherDate() Constructs a new Teacher Date representing today (the date at which the program is run). 2 of 6 public int getDay() Returns this Teacher Date's day of the month, between 1 and the number of days in that month (which will be between 28 and 31). public int getMonth() Returns this Teacher Date's month of the year, between 1 and 12. public int getYear() Returns this Teacher Date's year. public String getDayOfWeek () Returns a String representing what day of the week this TeacherDate falls on. The String will be either "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", or "Saturday". (1753/1/1 was a Monday) public boolean isLeapYear() Returns whether this Teacher Date's year is a leap year. Leap years are all years that are divisible by 4, except for years that are divisible by 100 but not by 400. For example, 1756, 1952, 2004, 1600, and 2000 are all leap years, but 1753,2005, 1700, and 1900 are not public void nextDay() Advances this Teacher Date to the next day after its current day. Note that this might advance the Teacher Date into the next month or year. For example, the next day after August 7 is August 8; the next day after December 31 is January 1; the next day after February 28, 2005 is March 1, 2005, and the next day after February 28, 2004 is February 29, 2004 (because 2004 is a leap year). public String toString() Returns a String representation of this Teacher Date, in a year/month/day format to match the following: "2005/5/24" Part B (Date class and TestDate): The second part of this problem asks you to implement a class named Date. Your Date class should implement the following behavior. None of the methods below should print any output to the console. You may not call any methods or utilize any behavior from the TeacherDate class to help implement your Date class (other than getDaysSinceEpoch, see below), nor use any of Java's date-related objects such as GregorianCalendar. Methods you must implement in your Date class: public Date(int year, int month, int day) Constructs a new Date representing the given year, month, and day. You may assume that the parameter values are valid. Since the modern Gregorian calendar was established in late 1752, you may assume that the year parameter value will be greater than or equal to 1753. public Date() Constructs a new Date representing today (the date at which the program is run). It may be helpful for you to know that the following expression returns the number of days that have elapsed since January 1, 1970. (You must import java.util.*; to be able to refer to Time Zone.) int daysSinceEpoch = (int) ((System.currentTimeMillis() + TimeZone.getDefault().getRawoffset()) / 1000 / 60 / 60 / 24); public int getDay() Returns this Date's day of the month, between 1 and the number of days in that month (which will be between 28 and 31). public int getMonth() Returns this Date's month of the year, between 1 and 12. public int getYear() Returns this Date's year. public String getDayOfWeek () Returns a String representing what day of the week this Date falls on. The String will be either "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", or "Saturday". For example, August 7, 2005 fell on a Sunday, so the 3 of 6 return value for a new Date (2005, 8, 7) object would be "Sunday". It may be helpful for you to know that January 1, 1753 was a Monday public boolean isLeap Year() Returns whether this Date's year is a leap year. Leap years are all years that are divisible by 4, except for years that are divisible by 100 but not by 400. For example, 1756, 1952, 2004, 1600, and 2000 are all leap years, but 1753, 2005, 1700, and 1900 are not. public void next Day() Advances this Date to the next day after its current day. Note that this might advance the Date into the next month or year. For example, the next day after August 7 is August 8; the next day after December 31 is January 1; the next day after February 28, 2005 is March 1, 2005, and the next day after February 28, 2004 is February 29, 2004 (because 2004 is a leap year). public String toString() Returns a String representation of this Date, in a year/month/day format to match the following: "2005/5/24" Hints: Complete Part A before Part B, to get a good understanding of how Date objects work. Write Part B in phases: Write the Date (year, month, day) constructor, getDay, getMonth, getYear, toString methods first. Then implement isLeapYear. Next, try to write nextDay. (You may wish to write a helping method that returns the number of days in this Date's month, to help you implement nextDay.) Lastly, write getDayOfWeek and the Date () 'today' constructor. You can use your nextDay method to help you write these methods. You can test your Date class by creating TestDate, a modified version of your Part A Birthday program that uses your Date instead of Teacher Date. Avoid redundancy and break down the overall problem into methods that each solve part of the overall problem. Your main method should still contain the overall control flow of the program. In Part B, in your Date class, you should use some global constants (Finals) in your program, to avoid "magic numbers." The choice of what constant to use is up to you, but it should represent an important value that is used in your class

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!