Photo AI

Do the following: 1 - NSC Information Technology - Question 2 - 2023 - Paper 1

Question icon

Question 2

Do-the-following:--1-NSC Information Technology-Question 2-2023-Paper 1.png

Do the following: 1. Open the incomplete project file called Question2_P.dpr in the Question 2 folder. 2. Enter your examination number as a comment in the first li... show full transcript

Worked Solution & Example Answer:Do the following: 1 - NSC Information Technology - Question 2 - 2023 - Paper 1

Step 1

Button [2.1.1 - Large enrolments]

96%

114 rated

Answer

To display the details of all courses in the tblCourses table accommodating 100 or more students, you can use the following SQL statement:

SELECT * FROM tblCourses 
WHERE MaxStudents >= 100;

Step 2

Button [2.1.2 - Lecturer gender]

99%

104 rated

Answer

To display the LecturerName, LecturerSurname, and calculate the first letter of the gender, use the SQL statement:

SELECT LecturerName, LecturerSurname,
LEFT(Gender, 1) AS 'Gender (M/F)'
FROM tblLecturers;

Step 3

Button [2.1.3 - Multilingual lecturers]

96%

101 rated

Answer

To retrieve the CourseID and CourseName of all courses that have multilingual lecturers, sort the results alphabetically by course name using the SQL statement:

SELECT CourseID, CourseName
FROM tblCourses
WHERE tblLectures.LecturerID = tblCourses.LecturerID 
AND Multilingual = TRUE
ORDER BY CourseName;

Step 4

Button [2.1.4 - Lecturer salaries]

98%

120 rated

Answer

To calculate and display the salary of lecturers based on the number of courses they facilitate, use:

SELECT LecturerID, 
FORMAT(COUNT(*) * 100000, 'C', 'en-ZA') AS Salary
FROM tblCourses
GROUP BY LecturerID;

Step 5

Button [2.2.1 - Average duration of courses]

97%

117 rated

Answer

To calculate the average duration of courses facilitated by each lecturer, use the following approach:

  1. Loop through all records in tblLecturers.
  2. For each lecturer, calculate the average duration and display as follows:
foreach Lecturer in tblLecturers do
begin
  totalDuration := 0;
  count := 0;
  writeLn(Lecturer.LecturerID + ': ' + Lecturer.LecturerName + ' ' + Lecturer.LecturerSurname);
  foreach Course in tblCourses do
  begin
    if Course.LecturerID = Lecturer.LecturerID then
    begin
      totalDuration += Course.Duration;
      count += 1;
      writeLn(count + '. ' + Course.CourseName);
    end;
  end;
  averageDuration := totalDuration / count;
  writeLn('Average duration of courses: ' + Format('%0.2f', [averageDuration]));
end;

Step 6

Button [2.2.2 - Register new lecturer]

97%

121 rated

Answer

To add a new lecturer record to the tblLecturers table, use:

tblLecturers.Insert();
  tblLecturers['LecturerID'] := 'ZT032';
  tblLecturers['LecturerName'] := 'Zander';
  tblLecturers['LecturerSurname'] := 'Thomas';
  tblLecturers['Gender'] := 'M';
  tblLecturers['Multilingual'] := True;

Join the NSC students using SimpleStudy...

97% of Students

Report Improved Results

98% of Students

Recommend to friends

100,000+

Students Supported

1 Million+

Questions answered

;