WhatsApp-00963951432013 Admin
عدد المساهمات : 2429 نقاط : 302124 السٌّمعَة : 4 تاريخ التسجيل : 20/09/2008 العمر : 54 الموقع : www.aoua.123.st
| موضوع: Page 1 / 5 M150B TMA – Fall 2015/2016 Cut-off date: Total marks: 80 This TMA should be submitted to your tutor electronically through the LMS system before the cut-off date indicated above. You should write your solutions to the questions in a الأربعاء نوفمبر 11, 2015 3:23 am | |
| Page 1 / 5 M150B TMA – Fall 2015/2016 Cut-off date: Total marks: 80 This TMA should be submitted to your tutor electronically through the LMS system before the cut-off date indicated above. You should write your solutions to the questions in a single word document. Head the document with your name and your Personal Identifier (ID). The TMA is marked out of 80, out of which 20% will be considered for the continuous assessment grade. It consists of 3 questions; 25 marks allocated for each question plus 5 marks for the programming style. Important note: − 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 you in getting high grade in this TMA. Arab Open University Faculty of Computer Studies M150 Data, computing and information Page 2 / 5 Question 1 [25 marks] Write JavaScript program for conversion between Fahrenheit and Celsius temperatures according to the following: a. Define a function celsiusToFahrenheit(temp). The function should calculate the Fahrenheit equivalence of temp and return the calculated value. b. Define another function fahrenheitToCelsius(temp) . The function should calculate the Celsius equivalence of temp and return the calculated value. c. Ask the user to choose whether to enter the temperature in Celsius or Fahrenheit. d. Read the temperature and print it in the output window. e. Use one of the two functions celsiusToFahrenheit and fahrenheitToCelsius to do the required conversion. Print the result in the output window. f. Run your program to make sure it works as specified. Provide three screenshots that show the output of your program in three different cases as follows: - One for the first prompt window. - One showing the result of conversion from Celsius to Fahrenheit. - One showing the result of conversion from Fahrenheit to Celsius. Note: If C is the temperature in Celsius and F Fahrenheit, the conversion formulas are: C = 5 X (F - 32) / 9 F = (9 X C / 5) + 32 Page 3 / 5 Question 2 [25 marks] In unit 9, you learnt that it is possible to use a function from its specification, without needing to know how it works. You also learnt how to import a function library into a JavaScript program and how to write simple programs that use a function library. The course book introduces three functions libraries: "dateLibrary", "drawingLibarary" and "stringLibrary". You can get the complete code and specification of these libraries from the course CD. Using functions from any of the given libraries, write JavaScript program to do the following: a. Draw a right arrow followed by a left arrow. The colors and lengths are left to your choice. b. Create a Date object representing the date 17 June 1999. c. Create another Date object of your choice. d. Print the two Date objects you've created in the long form (i.e. 17 June 1999) e. Calculate the differences in days and years between the two dates and print them in the output window. f. Change the month of the first Date object to be September. You should not create a new Date. g. Print the month name after changing (You need to use a function). h. Print two different shapes of your choice other than right and left arrows. i. Run your program to test it. Insert a screenshot showing your program output. Page 4 / 5 Question 3 [25 marks] You are required to model a new user-defined object type, Account . The Account object type has the following properties : name : a string that holds the Account holder name. balance : a number that holds the Account balance. The Account object type has the following methods : getName() : a method that returns the Account name . getBalance() : a method that returns the Account balance . credit(anAmount) : a method to add anAmount to the Account balance . debit(anAmount) : a method to debit the Account balance by anAmount only if anAmount is less than or equals to the Account balance . Otherwise keep the balance as it is and display an appropriate message (in an alert window). addInterest() : a method to add 5% interest to the Account balance . For example, if the Account balance is $ 5000, the interest will be 5000 * 5 / 100 = $ 250 and the new balance will be 5000 + 250 = $ 5250. display() : a method which displays in an alert box the holder name and balance of Account object. Note that both debit and credit methods should print a message stating the current balance on the account abject. Write JavaScript statements to do the following: a. Write the Account constructor function function Account (aName, aBalance) . b. Implement the methods getName() , getBalance() , credit(anAmount) , debit(anAmount) , addInterest() and display() according to the above specifications. c. Create an Account object and initialize all its two properties by values entered by the user. d. Use appropriate methods to do the following for the Account object you've created: 1. Debit the Account by any value that would result in an invalid transaction. The value need to be read from the user. 2. Debit the Account by any value that would result in a valid transaction. The value need to be read from the user. 3. Add interest to the Account. 4. Print the Account current information. e. In your Solution document insert screenshots showing one prompt window and all resulted alert boxes . Page 5 / 5 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 short comments at the beginning of each program stating the purpose of your program. • Using spacing and indentation to help making the structure of your program clear. • Making sure that the programs output include descriptive texts that clearly 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) - Avoid very short identifiers, such as a, b, x, ch, because they are not very informative. - Avoid the use of $ and _ in identifiers. - Choose meaningful names, i.e. names which give some indication of the role played by the variable. - Start your identifiers with lower-case letters. Where an identifier is composed of two or more English words use a single upper-case letter to mark the start of each word after the first. TMA submission: In addition to submitting a word file including the solution of the TMA questions, you need to submit the source code of all the programs required for the three questions of the TMA in separate files (.html). Put all your four files in one folder, compress it and send it through the LMS. Your TMA will not be marked if all the required files are not submitted. Good Luck GGoooodd LLuucckk Good Luck | |
|