CMPSCI 235 – Algorithm Project
You must design 3 algorithms, and provide both a flow chart and pseudo code for the algorithms.
Algorithm descriptions:
Given an integer parameter named current_number and two constant global variables:
const int MIN_NUMBER = 1;
const int MAX_NUMBER = 8;
Create an algorithm named forward, that will advance ONE value through a sequence of numbers 1, 2, 3 … MAX_NUMBER. In other words, when passed a value of 3 in the parameter current_number, it simply returns a 4.
However, when MAX_NUMBER is reached the algorithm should wrap around back and return MIN_NUMBER. The algorithm will NEVER return a value larger than MAX_NUMBER.
Create an algorithm named backward, that will move through a sequence of numbers … 3, 2, MIN_NUMBER. In other words, when passed a value of 6 in the parameter current_number, it simply returns a 5.
When MIN_NUMBER is reached the algorithm should STOP and return the value MIN_NUMBER. This algorithm will NEVER wrap around.
Create an algorithm named createFileName, that takes a number as input, current_number, and builds and returns a string like “pictureX.gif”, where X is the value in the input parameter.
This should fit on 1 sheet of paper. Place the 3 flowcharts on one side of the paper and the matching pseudo-code next to it or on the other side.
Last Completed Projects
topic title | academic level | Writer | delivered |
---|