Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

First, Beginning of the code, Please put on comment what's the purpose of this code and Methods on comment. And, Please do it on Repl.it

First, Beginning of the code, Please put on comment what's the purpose of this code and Methods on comment. And, Please do it on Repl.it and share the link.

Programme:

1) Design a class Date:

Provide 3 fields (int) to store the month number, the day number, and the year

Provide the following methods:

? Default constructor - sets date to 1, 1, 1900

? Constructor with parameters - if parameters are not valid, set to 1,1,1900

? setDate - if parameters are not valid, set to 1,1,1900

? Accessors for each field

? Mutators for each field - if parameter is not valid, do not set

? Print the day

? Return the next day (example: if current day is Friday return Saturday)

? Return the previous day (example: if current day is Tuesday, return Monday)

? Print a date in the formmm-dd-yyyy (example:11-25-2020 )

? Print a date with the month as a String(ex: March 20, 2010)

** Add any of the following methods for extra credit:

? Calculate and return the day by adding a number of days to the current day. Examples: if the

current day is Monday and we add 4 days, the day to return is Friday; if the current day is Tuesday

and we add 13 days, the day to return is Monday.

? Method to test whether the year is a leap year (return true if leap year, false otherwise)

? Method to return the number of days in the month

? Method to return the number of days passed in the year - from the current date

? Method to return the number of days remaining in the year - from the current date

? Method to calculate a new date by adding a fixed number of days to the date

? A method to print the calendar for the particular month

(can print a calendar for any month starting January 1, 1500.

Note that the day for January 1 of the year 1500 was a Monday. To calculate the first day of the

month, you can add the appropriate number of days to Monday, January 1, 1500.)

2) make a menu-driven program to test all the methods of your Date.

If the user wishes to print the calendar for a month use the format below

image text in transcribed
If the user wishes to print the calendar for a month use the format below September 2014 Sun Mon Tue Wed Thu Fri Sat 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions