Question
Chapter 7 Question 8 named DEBUG07- 01. txt, DEBUG07- 02. txt, and DEBUG07- 03. txt. Each file starts with some comments that describe the problem.
// The Date class contains a month, day, and year, and methods to set
// and display the values. The month cannot be set to less than 1 or more
// than 12, and the day of the month cannot be set to less than 1 or more
// than the number of days in that month. The demonstration program
// instantiates four Dates and purposely uses invalid values as some
// of the arguments; the class methods will correct the invalid values.
class Date
Fields
private num month
private num day
private num year
Methods
public void setDate(num mo, num da, num yr)
num HIGH_MONTH = 12
num HIGHEST_DAYS[HIGH_MONTH) =
31, 29, 31, 20, 31, 30, 31, 31, 30, 31, 30, 31
if month > HIGH_MONTH then
month = HIGH_MONTH
else
if mo
month = 1
else
mo = month
endif
endif
if da > HIGHEST_DAYS[month] then
day = HIGHEST_DAYS[month]
else
if da
da = 1
else
day = da
endif
yr = year
return
public void showDate()
output "Date: ", month,
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started