Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Create a project named Date. NetBeans will create a class with the same name, Date. The Date class that NetBeans creates will have a main

Create a project named Date. NetBeans will create a class with the same name, Date. The Date class that
NetBeans creates will have a main method in it but will not be the main class. Delete the main method that
NetBeans puts in the Date class and implement the Date class as described below. Then create another
class named DateDemo which will be the main class. It will contain the main method. Implement the
DateDemo class as described below.
The Date Class
Implement a Date class whose objects represent dates in the Gregorian calendar.
The Date class should have month, day and year, all integers, as instance variables.
The Date class should have the following methods:
public String getMonth()// returns the name of the month as a string (does not return the instance variable
// month)
public int getDay()// returns the instance variable day
public int getYear()// returns the instance variable year
public void setDate(int m, int d, int y)// sets the instance variables month, day and year to the input
// parameters m, d and y
public String getWeekDay // Returns the day of the week as a string
The DateDemo Class
Implement a DateDemo class that creates Date objects, modifies them, and prints them out in
day-of-the-week, month-name day, year format as shown in the sample output below.
The DateDemo class does the following:
1. Prompts the user for the first day of class.
2. Reads a string in the format mm/dd/yyyy and parses the string into three integers representing
the month, day and year.
Note: Refer to Lab 1 outline, which is posted on Moodle under Lab 1, for a detailed outline of step 2.
3. Repeats the two steps above for the last day of class.
4. Constructs two Date objects for the first day of class and the last day of class and sets the values of
their instance variables using the data that was entered.
5. Uses appropriate methods of the Date class and println statements to print the first day of class and
the last day of class as shown in the sample output below.
Note: Refer to Lab 1 outline, which is posted on Moodle under Lab 1, for a detailed outline of step 5.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Systems Design Implementation And Management

Authors: Carlos Coronel, Steven Morris

14th Edition

978-0357673034

More Books

Students also viewed these Databases questions