Photo AI

The local school's district office requires a record of schools in the district and a report on the results of the schools to determine the amount of funding that each school will receive - NSC Information Technology - Question 3 - 2023 - Paper 1

Question icon

Question 3

The-local-school's-district-office-requires-a-record-of-schools-in-the-district-and-a-report-on-the-results-of-the-schools-to-determine-the-amount-of-funding-that-each-school-will-receive-NSC Information Technology-Question 3-2023-Paper 1.png

The local school's district office requires a record of schools in the district and a report on the results of the schools to determine the amount of funding that ea... show full transcript

Worked Solution & Example Answer:The local school's district office requires a record of schools in the district and a report on the results of the schools to determine the amount of funding that each school will receive - NSC Information Technology - Question 3 - 2023 - Paper 1

Step 1

3.1.1 Constructor Create

96%

114 rated

Answer

To create the constructor, initialize the attributes by defining the parameters with appropriate types:

constructor Create(fSchoolName: string; fTotalLearners: integer; fPublicSchool: boolean);
begin
  SchoolName := fSchoolName;
  TotalLearners := fTotalLearners;
  PublicSchool := fPublicSchool;
  rRating := 'Z'; // Default rating
end;  

Step 2

3.1.2 Write an accessor method called getPublicSchool for the School class

99%

104 rated

Answer

Define the method to return the value of the PublicSchool attribute:

function getPublicSchool: boolean;
begin
  Result := PublicSchool;
end;

Step 3

3.1.3 Write code for a method called updateRating

96%

101 rated

Answer

The updateRating method should calculate the percentage of learners who passed and determine the rating:

procedure updateRating(passPercentage: integer);
begin
  passPercentage := (passPercentage / TotalLearners) * 100;
  if passPercentage >= 80 then
    rRating := 'A'  
  else if passPercentage >= 60 then
    rRating := 'B'  
  else
    rRating := 'C';
end;

Step 4

3.1.4 Write code for a method called calcFunding

98%

120 rated

Answer

This method calculates and returns the funding based on the number of learners enrolled:

function calcFunding: real;
begin
  Result := TotalLearners * 145.50;
end;

Step 5

3.1.5 Write code for a method called toString

97%

117 rated

Answer

The toString method constructs a string that provides information about the school:

function toString: string;
begin
  Result := SchoolName + '--------------' + sLineBreak +
            'Total number of learners: ' + IntToStr(TotalLearners) + sLineBreak +
            'Rating: ' + rRating + sLineBreak +
            If PublicSchool then 'Public school' else 'Private school';
end;

Step 6

3.2.1 Button [3.2.1 - Instantiate Object]

97%

121 rated

Answer

Extract the required data from the user input elements and instantiate the School object:

objSchool := TSchool.Create(edtQ3_2_1.Text, StrToInt(spnQ3_2_1.Text), chbQ3_2_1.Checked);
redQ3.Caption := objSchool.toString;

Step 7

3.2.2 Button [3.2.2 - Rating]

96%

114 rated

Answer

Use the entered total number of learners who passed to update the school rating and display the updated information:

updateRating(StrToInt(spnQ3_2_2.Text));
redQ3.Caption := objSchool.toString;

Step 8

3.2.3 Button [3.2.3 - Funding]

99%

104 rated

Answer

Determine whether the school is public or private and calculate the corresponding funding:

if objSchool.getPublicSchool then
  redQ3.Caption := 'Public school will receive R' + FloatToStr(objSchool.calcFunding)
else
  redQ3.Caption := 'No funding available';

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

;