ICT2613_103_1_2019.pdf

# Table displaying the doctors information on the web

• Notes
• 9

This preview shows pages 7–9. Sign up to view the full content.

table displaying the doctors’ information on the web page should be updated immediately to reflect the update, if successful. A function should be used to create and execute the query to update the doctors table. If the user chooses the Delete option, the PHP code should only read the practice number entered by the user. Deletion is only performed when the user-specified practice number already exists in the doctors table. The HTML table displaying the doctors’ information on the web page should be updated immediately to reflect the deletion, if deletion successful. A function should be used to create and execute the query to delete row from the doctors table. Task 5, page name: task5.php, chapter: 5 & 8, marks: 20 (a) Generate and display the following series of 20 numbers using one for loop. 1 1 [2] [4] 7 11 [16] [22] 29 37 [46] [56] 67 79 [92] [106] 121 137 [154] [172] To generate the series, you start with 1 and a counter initialized to 0. Then you add the counter (0) to the number (1) in the series to generate the second number in the series (1 + 0 = 1). Then you increment the counter by 1, which makes the counter 1. So in the next iteration add the

This preview has intentionally blurred sections. Sign up to view the full version.

counter value (1) to the last series number (1), which gives the next series number 2. Continue this calculation until 20 numbers are generated. Additionally even numbers are displayed using [ ] brackets (6) (b) Generate the same series using one while loop. However, this time, display the odd numbers in { } brackets as shown below: (6) {1} {1} 2 4 {7} {11} 16 22 {29} {37} 46 56 {67} {79} 92 106 {121} {137} 154 172 (c) In the South African schooling system, rating codes are used to indicate a learner’s level of competence, which is determined by the percentage of the final mark in a subject. Given below is a table that lists the rating codes, descriptions of achievement and the percentages of marks. RATING CODE DESCRIPTION % 7 Outstanding 80-100 6 Meritorious 70-79 5 Substantial 60-69 4 Adequate 50-59 3 Moderate 40-49 2 Elementary 30-39 1 Not achieved 0-29 Write a function that takes a final percentage and returns the correct rating code as indicated in the table above. If a number is less than 0 or greater than 100 is passed, it should return -1. You can assume that only a number will be passed to this function. You should use if else if constructs to code this function. Call this function with values 5, 40 and 101, and echo out the values returned by the function. Code another function that takes a rating code and returns the correct descriptions of achievement. If a rating code outside the range 1 to 7 is passed to the function, it should return the message ‘Invalid code’. You can assume that only a number will be passed to this function. You should use switch construct to code this function. Call this function with values 1, 7, -1, and echo out the values returned by the function. (8) Task 6, page name: task6.php, chapter: 5, 9, 10 & 11 marks: 20 (a) Present a form with a textbox where the user can enter a sentence. Demonstrate the purpose of the built-in string functions implode() and explode() by displaying appropriate output of these string functions on the input sentence. (5) (b) Write a function that accepts a DateTime object representing a birthdate of a person and does the following: Display the object in a suitable format that shows the day, month and year. For example 20/01/1974. Compute the age of the person from the given DateTime object and display this computed age. You can assume that only a valid DateTime object representing the birth date of a person who
is already born will be passed to the function. Test this function with three DateTime objects with the following dates: 29-03-1980, current date and 31-12-1996. (10) (c) Generate 10 random numbers between 1 and 5, and store these 15 random numbers in an array. Display the contents of the array along with the index of each element in a format of your choice. Demonstrate the use of the functions array_sum() and array_count_values() by invoking them on this array and displaying the results of these functions. (5) © UNISA 2019
This is the end of the preview. Sign up to access the rest of the document.
• Spring '12

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern