0% found this document useful (0 votes)
29 views4 pages

Design Document

The document describes a design for a menu with 9 options for a user including displaying, calculating totals and averages, finding largest/smallest numbers, counting occurrences, scaling values, reversing values, and setting a zero base. Test data is provided to demonstrate each case working with the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views4 pages

Design Document

The document describes a design for a menu with 9 options for a user including displaying, calculating totals and averages, finding largest/smallest numbers, counting occurrences, scaling values, reversing values, and setting a zero base. Test data is provided to demonstrate each case working with the numbers 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

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.

Case 4 Largest number

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.

Case 5 - Smallest number

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.

Case 6 Occurrences of a value

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

The test data we will be using to demonstrate the program: 1, 2, 3, 4, 5, 6, 7, 8, 9, 9, 9, 9

1 --Pressing 1 displays all numbers in the array

2 Pressing 2 displays the total of all numbers in the array

3Pressing 3 displays average of all numbers in the array 72/12 = 6


4Pressing 4 displays largest number in the array, which is 9

5 Pressing 5 displays smallest number in the array, which is 1

6When 6 is selected, the user is asked to input a number

The number 9 is checked and it occurs four times

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

8When 8 is selected, the values in the array are reversed

When 9 is selected, the zero base is performed. The smallest number in the array is now 0

99 exits the program

You might also like