Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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.

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. Comments are lines that begin with two slashes (//). Following the comments, each file contains pseudocode that has one or more bugs you must find and correct.

// 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

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

The Core Ios Developer S Cookbook Core Recipes For Programmers

Authors: Erica Sadun ,Rich Wardwell

5th Edition

0321948106, 978-0321948106

More Books

Students also viewed these Programming questions