Photo AI

SECTION C QUESTION 3: OBJECT-ORIENTATED PROGRAMMING Information on some of the popular hiking trails in South Africa are available in the format of text files - NSC Information Technology - Question 3 - 2021 - Paper 1

Question icon

Question 3

SECTION-C-QUESTION-3:-OBJECT-ORIENTATED-PROGRAMMING--Information-on-some-of-the-popular-hiking-trails-in-South-Africa-are-available-in-the-format-of-text-files-NSC Information Technology-Question 3-2021-Paper 1.png

SECTION C QUESTION 3: OBJECT-ORIENTATED PROGRAMMING Information on some of the popular hiking trails in South Africa are available in the format of text files. The ... show full transcript

Worked Solution & Example Answer:SECTION C QUESTION 3: OBJECT-ORIENTATED PROGRAMMING Information on some of the popular hiking trails in South Africa are available in the format of text files - NSC Information Technology - Question 3 - 2021 - Paper 1

Step 1

Button [3.2.2 - Display hiking trail details]

96%

114 rated

Answer

To display the hiking trail details using the toString method, write the following code:

procedure DisplayHikingTrailDetails;
begin
  redQ3_2.Text := objHikingTrail.toString;
end;

This code will set the text of the redQ3_2 component to the string representation of the objHikingTrail, which contains the name, terrain type, distance, and cost details.

Step 2

Button [3.2.3 - Display cost]

99%

104 rated

Answer

To calculate the cost for the group, implement the following steps:

procedure DisplayCost;
var
  numberOfHikers: Integer;
begin
  numberOfHikers := StrToInt(InputBox('Enter number of hikers in group', 'Number of Hikers', ''));
  costVariable := objHikingTrail.calculateCost(numberOfHikers);
  ShowMessage('Cost of group is: R' + FloatToStr(costVariable));
end;

This code prompts the user to input the number of hikers, calculates the total cost using the calculateCost method, and then displays the result in a message box.

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

;