Structured programming and subroutines (procedures and functions)

EasyMediumHard
1234567891011121314
Question 7
Hard

Write a subroutine in C# called checkTreasure that will count the number of treasure chest symbols ('T') on a map grid.

An example of the 2D array islandMap is shown in Figure 1.

Figure 1

0123
0'W''L''T''W'
1'T''W''L''W'
2'L''L''T''T'

The subroutine should:

  • take the 2D array islandMap of characters as a parameter
  • count the number of 'T' characters in the islandMap array
  • output the word Jackpot if there are five or more 'T' symbols in the array
  • output the total number of 'T' symbols if there are fewer than five 'T' symbols in the array.

You must write your own count routine and not use any built-in search or count functions that might be available in C#.

You should use meaningful variable name(s) and C# syntax in your answer.

[8]

Structured programming and subroutines (procedures and functions) Questions

  1. GCSE
  2. /Computer Science
  3. /Structured programming and subroutines (procedures and functions)