Lab Exercise - C++ Classes Create a Date class that contains: Three private data members:...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Lab Exercise - C++ Classes Create a "Date" class that contains: • Three private data members: a month day o year "setters" and "getters" for each of the data (6 functions in total) • One advantage of a "setter" is that it can provide error checking. Add assert statements to the setter to enforce reasonable conditions. For example, day might be restricted to between 1 and 31 inclusive. one default constructor (no arguments). Assign default values to the date. Example: 1,1,1 one constructor with three arguments: month, day, and year • Add statements to enforce reasonable conditions. . a print Date function. This function will have no arguments and return void. • a sameMonth function. This function will have one Date argument and a boolean return type. In main (in the following order): 1. Instantiate one date object (datel) using the default constructor 2. Use the getter methods to display the month, day, and year of datel (should print the default values) 3. Read keyboard input from the user for a month, day and year 4. Use the setters to set the values of datel to the values that came from the user 5. Read keyboard input from the user for a second date 6. Use the constructor with three arguments to instantiate date2 to the second date input from the user 7. Print both objects using print Date 8. Print a message to say if the two months are the same (testing the sameMonth function) Your code should be in three files: Date.h contains the class definition Date.cpp includes "Date.h" 。 contains the functions for the class • main.cpp includes "Date.h" tests the class Sample Output Testing the default constructor and the getters The initialized date is (M-D-Y):1-1-1 Please enter a date: (Month Day Year): 11 03 1976 Please enter a second date: (Month Day Year): 03 03 1999 Printing the two days: The date is (M-D-Y): 11-3-1976 The date is (M-D-Y): 3-3-1999 The months are different Lab Exercise - C++ Classes Create a "Date" class that contains: • Three private data members: a month day o year "setters" and "getters" for each of the data (6 functions in total) • One advantage of a "setter" is that it can provide error checking. Add assert statements to the setter to enforce reasonable conditions. For example, day might be restricted to between 1 and 31 inclusive. one default constructor (no arguments). Assign default values to the date. Example: 1,1,1 one constructor with three arguments: month, day, and year • Add statements to enforce reasonable conditions. . a print Date function. This function will have no arguments and return void. • a sameMonth function. This function will have one Date argument and a boolean return type. In main (in the following order): 1. Instantiate one date object (datel) using the default constructor 2. Use the getter methods to display the month, day, and year of datel (should print the default values) 3. Read keyboard input from the user for a month, day and year 4. Use the setters to set the values of datel to the values that came from the user 5. Read keyboard input from the user for a second date 6. Use the constructor with three arguments to instantiate date2 to the second date input from the user 7. Print both objects using print Date 8. Print a message to say if the two months are the same (testing the sameMonth function) Your code should be in three files: Date.h contains the class definition Date.cpp includes "Date.h" 。 contains the functions for the class • main.cpp includes "Date.h" tests the class Sample Output Testing the default constructor and the getters The initialized date is (M-D-Y):1-1-1 Please enter a date: (Month Day Year): 11 03 1976 Please enter a second date: (Month Day Year): 03 03 1999 Printing the two days: The date is (M-D-Y): 11-3-1976 The date is (M-D-Y): 3-3-1999 The months are different
Expert Answer:
Answer rating: 100% (QA)
Dateh ifndef DATEH define DATEH include include include class Date private int month int day int yea... View the full answer
Related Book For
Posted Date:
Students also viewed these electrical engineering questions
-
For each of the Boolean functions given below, state whether the problem is linearly separable. (a) A AND B AND C (b) NOT A AND B (c) (A OR B) AND (A OR C) (d) (A XOR B) AND (A OR B)
-
Provide a reasonable explanation for each of the following observations: (a) 4-Methylpiperidine has a higher boiling point than N-methylpiperidine. (b) Two isomeric quaternary ammonium salts are...
-
For each of the following electronic payment systems, give an example of a company for which it might be applicable: a. Traditional electronic bill payment system b. Traditional credit card system c....
-
A company currently sells 8,280 basketballs (units) per year for $25 each. The company can make up to 10,280 basketballs per year. Each basketball made includes $15 In variable costs and $6.50 of...
-
The city of St. Louis, Missouri, is considering various proposals regarding the disposal of used tires. All of the proposals involve shredding, but the charges for the service and the handling of the...
-
Derive the result of Equation (4.12) for the range R. dE M -F(;), q?ne d3 R = = - dr
-
Do stakeholders influence environmental accounting systems? Do environmental accounting systems influence stakeholders? Provide an example to illustrate your argument.
-
Santana Rey expects sales of her line of computer workstation furniture to equal 300 workstations (at a sales price of $3,000) for 2016. The workstations' manufacturing costs include the following....
-
14. Determine the equation of the conic graphed below. -5. y 10 -5. X 14. 15. Change the following equation to Standard Form. 4x - y - 24x 4y + 16 = 0 Page 9 of 11 15. 3 marks 3 marks
-
You have just been hired as a brand manager at Kelsey-White, an American multinational consumer goods company. Recently the firm invested in the development of K-W Vision, a series of systems and...
-
Which statement is not true about variables? a). a variable is used to represent a quantity whose values may change or vary. b). letters are often used as variable c). a variable is a rule showing...
-
Accounts Receivable Accounts Payable Cash Land Prepaid Rent (6-months) Retained Earnings Supplies Using the above financial statement line items, calculate Total Current Assets. $1,000 $2,000 $2,000...
-
Describe the challenges and solutions associated with running RTOS on multicore architectures. How do RTOS manage task scheduling and resource sharing across multiple cores to maintain real-time...
-
Total fixed costs are $32,200 for Cullumber Inc. It has a unit contribution margin of $19 and a contribution margin ratio of 35%. Compute the break-even point in sales dollars. Break-even point in...
-
Given y = -log x, what is x when y = 5?
-
On January 1, 2024, Kingbird Company sold property to Ivanhoe Company which originally cost Kingbird $2750000. There was no established exchange price for this property. Ivanhoe gave Kingbird a...
-
Question 2 Assume that a firm involves on a competitive market. There are 50 firms. Total Cost 130 175 Quantity 01234567 7 8 9 205 235 255 280 310 350 410 490 Variable Cost 130 Marginal Cost 15000LC...
-
In Problem use absolute value on a graphing calculator to find the area between the curve and the x axis over the given interval. Find answers to two decimal places. y = x 3 ln x; 0.1 x 3.1
-
An advertisement for SeldaneD, a (now discontinued) drug prescribed for seasonal allergic rhinitis, reported results of a double-blinda study in which 374 patients took Seldane-D and 193 took a...
-
The relative risk of dying from all causes for women under age 70, for those who do not attend weekly religious services compared with those who do, is 1.22.
-
If each of the following measurements were to be taken on a group of 50 college students (once only for each student), it is unlikely that all 50 of them would yield the same value. In other words,...
-
(a) Consider a silicon pn junction diode operating in the forward-bias region. Determine the increase in forward-bias voltage that will cause a factor of 10 increase in current. (b) Repeat part (a)...
-
A silicon pn junction diode has an emission coefficient of \(n=1\). The diode current is \(I_{D}=1 \mathrm{~mA}\) when \(V_{D}=0.7 \mathrm{~V}\). (a) What is the reverse-bias saturation current? (b)...
-
(a) The reverse-saturation current of a gallium arsenide pn junction diode is \(I_{S}=10^{-22} \mathrm{~A}\). Determine the diode current for diode voltages of \(0.8,1.0\), \(1.2,-0.02,-0.2\), and...
Study smarter with the SolutionInn App