Design Document
Design Document
At the beginning of the project we had to create a menu with 9 options available for use by the user. We
each had a hand in this and worked together to come up with a design we were all happy with.
Bethany was then given the task of writing the code for the first three options. They were display, total and
average.
Jamie was given the task of writing the next three options which were smallest, largest and to count the
number of occurrences.
Ross was then given the last three to write which were scale up, reverse and find the zero base.
Case 1 - Display:
To start we had to create the whole project inside a do while loop and then have the options in a switch
statement. For case 1, I had to create a for loop which cycles through the numbers in the array and then
used a cout statement to output them to the screen for the user.
Case 2- Total:
Case 2 displays the total of numbers that is input by the user. A for loop again cycles through the numbers
in the array but this time it adds them altogether and then outputs all the input numbers added together
to give the total.
Case 3 Average:
For case 3 I had to write the code to display the average of all the numbers input. To do this I had to use
the same for loop from above to calculate the total and then after the for loop I divided the divided the
total answer by 12 as it is the amount of numbers entered and then the average is displayed to the user on
the screen.
To find the largest number in the array, I first created a location in memory called largest. Then I
created a For loop that cycles through all the numbers in the array. Using an If statement, the
program overwrites whatever value is in the variable largest if the number in the array is greater
than the number in largest.
To find the smallest number in the array, I first created a location in memory called smallest. I then
populated it with the first number in the array. Then, using a For loop and If statement, the program
cycles through all the numbers in the array. If any number in the array is less than the value of the
variable smallest, the program populates the variable with that number.
I created a memory location called occ for occurrences, and also a variable called num which will
be used to store the number that the user inputs. A cout statement asks the user to input a value
that they want to check how many times that value occurred in the array. Using a For loop and an If
statement, the program cycles through all the values in the array, and if the number that the user
entered is equal to a value in the array, the variable occ is incremented. E.g. if the number that a
user enters occurs three times in the array, occ will be incremented three times.
Test Data
7 When 7 is selected, the user is asked to input a scale factor. A scale factor of 2 is entered
The values in the array are multiplied by 2
When 9 is selected, the zero base is performed. The smallest number in the array is now 0