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 implement the toString method for displaying the hiking trail details, you should follow these steps:

  1. Define the toString method in the HikingTrail class that formats the necessary information as a string.
  2. Ensure that it includes:
    • trailName
    • terrainType
    • distance and number of days
    • Cost per person
  3. For example, the output if the Amatola Hiking Trail is selected should look like:
    Hiking trail information: Amatola Hiking Trail: Rocky 100 km long in 6 days Cost per person: R1,500.00.

Step 2

Button [3.2.3 - Display cost]

99%

104 rated

Answer

To implement the cost calculation based on the number of hikers, adhere to the following steps:

  1. Use an input box to request the number of hikers in the group. You may use:
    var
      groupSize: Integer;
    begin
    groupSize := InputBox('Enter number of people in group:', 'Number of Hikers', '');
    
  2. Call the calculateCost method using the formula:
    cost := objHikingTrail.calculateCost(groupSize);
    
  3. Display the calculated cost using a message box:
    ShowMessage('Cost of the group is: R' + FloatToStr(cost));
    
    Ensure that the cost correctly reflects the total for the number of hikers.

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

;