Requirement #5: Writing another program

\(\boxed{\mathbb{REQ}\Large \rightsquigarrow}\) In a programming language that may be the same or different from the programing language used above, write a program selected from the following list. Work with your counselor to define the requirements — input from a user or from a file? Output to the screen or to a file? You may not use a GUI-based programming interface for this requirement, but a language like Python, Small Basic or Lisps (a family of powerful, syntax-light languages including Scheme or Common Lisp) would be appropriate.

  1. A program that generates a random whole number between 1 and 10 and then asks the user to guess the number. When the guess is not correct, the program tells the user that the guess is too high or too low and then asks the user to try again. The program completes when the user correctly guesses the number.

  2. A program that correctly sorts in ascending order, a sequence of at least 15 input numbers.

  3. A program that accepts input, performs a calculation on the input and produces an output based on the input. It must use a function with one or more parameters to perform the calculation.

  4. A program that takes a set of at least 15 characters from a user and then displays the string in reverse order.

  5. A program that displays an interactive webpage that accepts user input and modifies its display based on the input (See Web Lab for example)

  6. A computer game of your choosing which uses interactive characters, requires skill and reports a winner or a loser. (See Game Lab for example)

  7. Any other computer program agreed on by you and your counselor that uses both variables and control flow instructions.

Tip

What is a random number? (answers adapted from random.org)

With the advent of computers, programmers recognized the need for a means of introducing randomness into a computer program. However, surprising as it may seem, it is difficult to get a computer to do something by chance. A computer follows its instructions blindly and is therefore completely predictable. (A computer that doesn’t follow its instructions in this manner is broken.) There are two main approaches to generating random numbers using a computer: Pseudo-Random Number Generators (PRNGs) and True Random Number Generators (TRNGs). The approaches have quite different characteristics and each has its pros and cons.

Random numbers are useful for a variety of purposes, such as generating data encryption keys, simulating and modeling complex phenomena and for selecting random samples from larger data sets. They have also been used aesthetically, for example in literature and music, and are of course ever popular for games and gambling. When discussing single numbers, a random number is one that is drawn from a set of possible values, each of which is equally probable, i.e., a uniform distribution. When discussing a sequence of random numbers, each number drawn must be statistically independent of the others.

alternate text

Example of random numbers that can be generated by a computer (the image was obtained from quora.com)

Attention

Once you have completed this requirement, make sure you document it in your worksheet!