C++代写:CS104 Diving Competition




To practise and assess everything up to and including repetition.

Learning outcome/s being assessed

  • outcomes already assessed
  • repetition (loops)


Write a program, run it, and test that it is performing correctly for all cases.


Test widely, especially cases that are not simple.

Marking criteria

As for Assignment 1


At a diving competition, the mark given to each diver is awarded as follows. There are a number of judges, and each judge gives a mark. The final mark is found by leaving out the highest and lowest marks and calculating the average of the rest of the marks.

Write a C++ program that: reads in the number of judges at the competition and then reads in a mark for each judge. Perform the necessary calculations, and display (to 2 decimal places) the final mark.

The following data checks must be carried out in the program:

  • the number of judges must be from 4 to 8 inclusive
  • each judge must give a mark between 0.0 and 10.0 inclusive (a real number that may include fractions)

If an invalid value is entered (for number of judges or for the mark), the program must ask for an acceptable value to be entered instead.

Example 1

Enter number of judges: 2
Invalid. Enter number of judges again (4 to 8): 4
Enter mark: 3.5
Enter mark: 6.0
Enter mark: 6.0
Enter mark: 9.75
Final mark: 6.0

Example 2

Enter number of judges: 5
Enter mark: 10.0
Enter mark: 13.75
Invalid. Enter mark again (0.0 to 10.0): 9.0
Enter mark: 3.0
Enter mark: 9.25
Enter mark: 8.8
Final mark: 9.02


  1. Your display should be similar to the examples above.
  2. Remember to test your program with several different examples.
  3. Remember to test what happens if invalid data is entered