IGCSE cs 0478 2023 Jun 23 11

IGCSE cs 0478 2023 Jun 23 11

A two-dimensional (2D) array Contacts[] is used to store names and telephone numbers. All the data is stored as strings. The array must have the capacity to store 100 contacts in the form of:

  • column 1 – contact names as: last name, first name for example: Smith, John

  • column 2 – telephone numbers.

The variable CurrentSize shows how many contacts are in the array. Write a program that meets the following requirements:

  • display a menu of choices:

    • enter new contact details

    • display all the contact details

    • delete all the contact details

  • validate the menu input

  • allow up to a maximum of five new contacts to be added to the array at any one time

  • do not allow more than 100 contacts in total

  • after new contacts have been added, sort the array by contact name, as long as there are at least two contacts in the array

  • output the whole of the array

  • delete the contents of the array.

You must use pseudocode or program code and add comments to explain how your code works. You do not need to declare any arrays, variables or constants; you may assume that this has already been done.

All inputs and outputs must contain suitable messages.

You do not need to initialise the data in the array Contacts[] and the variable CurrentSize

Python版初始化代码,练习的时候使用如下的代码

图解

Python版答案

Last updated

Was this helpful?