# Algorithm Development

### General Algorithms

A key piece of programming is creating appropriate algorithms to be translated into code. Given that JAWS does not play nicely with any of the programming environments I know about, instead of generating finished code, you will be generating the prerequisite algorithms.

To write an algorithm, you must specify each step necessary to solve the problem. As an example, consider making a peanut butter and jelly sandwich. Your first attempt at an algorithm might be something like this:

1. Get bread, peanut butter and jelly.
2. Put peanut butter on bread.
Unfortunately, this algorithm does not have enough detail to successfully create a delicious sandwich. Consider the second step: Put peanut butter on bread. How will this be accomplished? There are actually many steps involved, including opening the jar, grabbing a knife by the handle and continuing to hold on, placing the sharp end of the knife into the jar and swirling (in order to get peanut butter to stick to the knife blade), pulling the knife out of the jar, spreading peanut butter over the face of a piece of bread, etc. In general, when you write an algorithm you must be very precise, and try to make as few assumptions as possible. Sometimes its helpful to think ahead to all the ways your directions could be misinterpreted.

Exercise 1

Write an algorithm to create a favorite drink. For example, you might give a specification for making coffee, or a fruit smoothie. Just be sure there are more than 2 steps.

### Algorithms for Processing

Each programming language has some basic building blocks that it supports. In class we discussed the Processing language which has building blocks to do basic drawing functions, many mathematical functions (including addition, subtractions, multiplication, division, sine and cosine), offers the ability to prompt the user for an input, and get that input from the user, as well as deliver some output.

Exercise 2

Write an algorithm for a program that would convert a temperature in celcius to farenheit. Specify all interactions necessary as well as the mathematical operations (feel free to search online for the appropriate formula).

## Submitting

E-mail me (smn4@calvin.edu) both exercise solutions. You can write them up in Word, or a text editor of your choice.