Maximum+&+Minimum+(programming)

Introduction
Finding the maximum and finding the minimum are very similar algorithms. Maximum repeats through a list of numbers looking for the greatest number in the list, while minimum repeats through a list of numbers looking for the smallest number in the list.

A list of numbers is as follows: 1 7  8  7  4  3  5
 * Example**

Find the maximum number in the list.

The program starts by setting the current maximum number to 0. The program then repeats through the list comparing each number with the current maximum number. If the number in the list is greater than the current maximum, then the current maximum is set to the number in the list.

The first number in the list is 1. Is this greater than the current maximum (0)? Yes. The current maximum is set to 1. The next number in the list is 7. Is this greater than the current maximum (1)? Yes. The current maximum is set to 7. The next number in the list is 8. Is this greater than the current maximum (7)? Yes. The current maximum is set to 8. The next number in the list is 7. Is this greater than the current maximum (8)? No.

The program will continue to loop through the full list of numbers, and at the end display the current maximum.

Finding the minimum number in a list works in exactly the same way except: (i) At the start of the program the minimum number is set to a number greater than the numbers in the list e.g. 999 (i) Each number in the list is compared to see if it is less than the current minimum, and if so the current minimum is set to that value

Specification
Write a program which finds the maximum number in a list of numbers

Input Process Output
Inputs: None Process: Find the maximum Output: Maximum number in the list

Algorithm
1. set max to 0 2. repeat for all numbers in list

2.1 if current_number > max then 2.1.1 max = current_number 2.2 end if

3. end repeat 4. display max

The Task
1. Draw a screen design, with labelled fields and buttons 2. Copy the algorithm 3. Write the program

Extension
Adapt your program so that it also displays the minimum number from the list