WhatsApp-00963951432013 Admin
عدد المساهمات : 2429 نقاط : 302124 السٌّمعَة : 4 تاريخ التسجيل : 20/09/2008 العمر : 54 الموقع : www.aoua.123.st
| موضوع: M150 Data, computing and information الخميس نوفمبر 16, 2017 2:07 am | |
| M150B TMA – Fall 2017/2018 Cut-off date: To be announced Total marks: 80 This TMA should be submitted to your tutor electronically through the LMS system before the cut-off date indicated above. The TMA is marked out of 80, out of which 20% will be considered for your continuous assessment grade. It consists of 2 questions: 35 marks for question1, 40 marks for question2 and 5 marks for the programming style. Before you start working with this assignment, you need to refer to section 8.2 of the M150 course companion to read about plagiarism and how to avoid it. This will help to get high grade in this TMA. Arab Open University Faculty of Computer Studies M150 Data, computing and information Page 2 / 4 Question 1 [35 marks] In this question you need to use functions from the "dateLibrary.js" in addition to some of the Date object methods you've learnt in unit 9. The specifications of all the functions in the "dateLibrary.js" library are in Appendix 1 at the end of unit 9. 1. Write a function called myLeapYearFunction(aDate) that takes a Date object as its argument. The function checks if aDate falls in a leap year and displays an appropriate message in the output window accordingly. The function should use the function isLeapYear() from the "dateLibrary.js". 2. Now, you need to do the following: a. Create any date in the year 2000 and print it in the long form (i.e. including the month name). b. Calculate the difference in days and years between today's date and the date you've just created and print them in the output window. Do the following to the date you've created in a.: c. Change the year to be 2018 and print the date again in the long form. d. Call the function myLeapYearFunction() to check whether it falls in a leap year. 3. Insert a screenshot that shows the resulted output of your code. Page 3 / 4 Question 2 [40 marks] You are required to model a new user-defined object type, Worker. The Worker object type has the following properties: name: a string representing the name of the worker. hourlyWage: a number representing the hourly wage of the worker in dollars. hours: a number representing the total number of working hours worked by the worker. The Worker object type has the following methods: getName(): a method that returns the name of the worker. getHourlyWage(): a method that returns the hourlyWage of the worker. getHours():a method that returns the hours worked by of the worker. calculatePayment():a method that calculates the total payment of the worker. This is calculated by multiplying the hours worked by the hourly wage of the worker. For example, if a worker worked for 40 hours and his hourly wage is 35$, then his payment will be 40 X 35 which is 1400$. printDetails(): a method that displays (in an alert window) the name, hourly wage, hours worked and total payment of the worker. The method should use the available methods of the Worker object. a. Write the Worker constructor function function Worker (aName, anHourlyWage, numberOfHours). b. Implement all the Worker methods according to the above specifications. c. Prompt the user for values of name, hourly wage and total number of hours worked by the Worker object to be created. d. Create a Worker object and initialize its properties by the values entered by the user. e. Print the Worker object information using the printDetails() method. f. Run your program. In your Solution document insert two screenshots: [4] − one showing the program prompting for the Worker name, with you having entered your name but not yet pressed OK; − one showing the resulted alert window. g. Change the hourlyWage of the Worker instance. You need first to read the new value of hourly wage from the user. h. Print the Worker instance information again and provide another screenshot showing the resulted alert window. Page 4 / 4 Programming style [5 marks]: In your answers to questions 1, 2 and 3, you should follow good programming style that helps readability. This includes: • Using comments at the beginning of each program stating the purpose of it. • Using spacing and indentation to help making the structure of your program clear. • The output of programs includes descriptive texts that describe the resulted output. • Following the M150 style guidelines when choosing the names of the variables. This includes: (Refer to section 2.2 of unit 7, page 16) - Avoiding very short identifiers, such as a, b, x, ch. - Avoiding the use of $ and _ in identifiers. - Choosing meaningful names that give indication of the role played by the variable. - Starting your identifiers with lower-case letters. TMA submission: You should write your solutions to all the questions with the required screenshots in a single word document. Head the document with your name and your student ID. End of question | |
|