Write specifications using UML notation for a function that computes the sum of the first five positive integers in an array of n arbitrary integers.

What will be an ideal response?

```
The specifications include type definitions, arguments, and preconditions and postconditions.
// Computes the sum of the first 5 positive integers in an array anArray.
// Precondition: The array anArray contains n integers, n >= 5;
// at least 5 integers in anArray are positive.
// Postcondition: Returns the sum of the first 5 positive integers in
// anArray; anArray and n are unchanged.
sumOf(in anArray: arrayType, in n: integer): integer
Another solution:
// Computes the sum of the first 5 positive integers
// in an array anArray.
// Precondition: The array anArray contains n integers.
// Postcondition: If anArray contains at least 5 positive integers,
// returns their sum; otherwise, returns 0. anArray and n are unchanged.
sumOf(in anArray: arrayType, in n:integer): integer

```

Computer Science & Information Technology

You might also like to view...

A(n) __________ is a location in the computer's memory where a value can be stored for use by a program.

a) unknown b) name c) variable d) declaration

Computer Science & Information Technology

Write an IOS command so that the addresses in the private network are mapped to the public IP address 128.143.136.80.

What will be an ideal response?

Computer Science & Information Technology