COSC 1046 (SF14) - Introduction to Computer Science
ThehonestCOSC 1046 (SF14) - Introduction to Computer Science
Assignment #6
NOTE: You must include commenting in all of these assignments. The code must be neatly
formatted – marks will be deducted.
Part A: These questions are to be submitted to the instructor in the form of a Word (or Open
Office) document containing the Java code and appropriate screen capture(s) of the output.
Put both questions in the same word file. The file name must be in the form
ASSIGN6A_YourName where ‘YourName’ is your last name followed by your first name with
no space. Upload the file to CMS.
Question 8.11, page 333:
10 marks for the class and test program. Another 10 marks for the UML diagram.
Question 9.29, page 368:
Test the program using: i) 978013213080; ii) 978013213079; and iii) 978013293652
Part B: Write code and test the solutions for the following problems from the textbook.
Submit the .java files for each question to CMS.
Question 8.7, page 331
Make sure you provide the test class to demonstrate the operations as described.
Question 9.5, page 363
Question 10.5, page 401
Programming 5
In programming exercise 2, the class Date was designed implemented to keep track of the date, but it has very limited operations. Redefine the class Date so that, in addition to the operations already define, it can perform the following operations on a date:
Set the month
Set the day
Set the year
Return the month
Return the day
Return the year
Tests whether a year is a leap year
Return the number of days in the month. For example, if the day is 3 – 12 – 2015, the number of days to be returned is 31, because there are 31 days in March.
Return the number of days passed in the year. For example, if the date is 3 – 18 – 2015, the number of days past in the year is 77. Note that the number of days returned also includes the current day.
Return the number of days remaining in year. For example, if the date is 3 – 18 – 2015, the number of days remaining in the year is 288.
Calculate the new date by adding a fixed number of days to the date. For example, if the date is 3 – 18 – 2015 and the days to be added on 25, the new date is 4 – 12 – 2015.
Return a reference to the object containing a copy of the date.
Make a copy of another date. Given a reference to an object containing a date, copy the data members of the object into the corresponding data members of this object.
Write the definitions of the methods to implement the operations defined for the class Date.
Part A: These questions are to be submitted to the instructor in the form of a Word (or Open Office) document containing the Java code and appropriate screen capture(s) of the output. Put both questions in the same word file. The file name must be in the form ASSIGN6A_YourName where‘YourName’isyourlastnamefollowedbyyourfirstnamewith no space. Upload the file to CMS.
Question 8.11, page 333:
10 marks for the class and test program. Another 10 marks for the UML diagram.
Problem 9.29, page 368:
Test the program using: i) 978013213080; ii) 978013213079; and iii) 978013293652
Part B: Write code and test the solutions for the following problems from the textbook. Submit the .java files for each question to CMS. The answers are due on May 28th and the programs are to be demonstrated to the Teaching Assistant (Daniel) by May 29th. He will ask questions to make sure you understand the material.
Question 8.7, page 331
Make sure you provide the test class to demonstrate the operations as described.
Problem 9.5, page 363
Problem 10.5, page 401
- 7 years ago
Purchase the answer to view it
- assign6a_yourname_part_a.zip