Question: In Java Write a program, that first prompt the user for today's date and for his/her birthday, each as a month-day-year. Use this information to

In Java

Write a program, that first prompt the user for today's date and for his/her birthday, each as a month-day-year. Use this information to print the number of days in the month the user was born, and the number of days from today to the user's birthday. If the user's birthday is today, print a Happy Birthday message. You have to implement the following methods.

public Date(int month, int day) Constructs a new Date representing the given month and day. Assumes that the parameter values passed are valid (month between 1 and 12, day appropriate for the month).

public int getMonth() Returns a Date object's month of the year, between 1 and 12. For example, if the Date object represents August 17, this method should return 8.

public int getDay() Returns a Date object's day of the month, between 1 and the number of days in that month (which will be between 28 and 31). For example, if the Date object represents August 17, this method should return 17.

public String toString() Returns a String representation of a Date in a month/day format. The day should always be shown as two digits; if the day is between 1 and 9, it should be preceded by a 0. For example, if the Date object represents May 24, it returns "5/24". If this Date object represents December 3, it returns "12/03". Note that this method returns the string; it does not print any output.

public int daysInMonth() Returns the number of days in the month represented by a Date object.

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!