Quick Index
Algorithm - Serving a Beverage


Writing an Algorithm for Serving a Beverage
Problem Statement: Write an algorithm to serve orange juice or milk to our auntie who is sitting at the kitchen table.
Auntie will choose one of the two beverages. Also allow auntie to choose between a small and large glass. Glass should be filled to one inch from the top. Wash hands before starting.

Given: We have a clean kitchen with all the necessary dishes, utensils, and ingredients. Drinking glasses are in the cupboard. Assume there is an obvious difference (in cupboard) between a small and large glass. Beverage containers are in the fridge. Cleanup steps do not need to be included.

Write the algorithm in human language (English). As always, we assume the algorithm "doer" knows nothing about this subject.

  • Wash hands
  • Ask auntie if she would like orange juice or milk
  • Remember answer as beverageChoice
  • Ask Auntie how big of a glass she would like
  • Remember answer as beverageSize
  • Get sufficiently large glass out of cupboard to match beverageSize
  • Open fridge
  • Remove beverage container that matches beverageChoice
  • Remove cap from beverage container
  • Fill up glass up with beverage -- to within one inch of top
  • Replace cap on beverage container
  • Put beverage container back into fridge
  • Serve beverage to Auntie

Algorithm - Adding a Computer Directory


Writing an Algorithm for Adding a Computer Directory
Problem Statement: Write an algorithm to create a computer directory "\foo" on a computer. Assume the directory does not exist before starting.

Given:

  • We can open a "file browser" as our main tool
  • We can navigate to any existing directory which will then be our "current directory"

These are the commands we have available in the "file browser":

  • "Right-click -- Create Directory", which prompts for a name (input), and then requires the "Enter" key to finish the command. A new directory is added with the name that was input.

Note: these commands apply to the current directory shown in the "file browser"

Write the algorithm, in human language (English). As always, we assume the algorithm "doer" knows nothing about this subject.

Make the steps operating system independent -- e.g., no Windows/Mac specific commands. Use commands from above-mentioned "popup".

  • Open a file browser
  • Navigate (in file browser) to root directory "\"
  • In the file browser, right click
  • Choose action "Create Directory"
  • On prompt enter name "foo"
  • Press "Enter" Key