CMPT 166 Spring 2009 Lab Assignments

Lab 0: HelloWorld (due Wed 14 Jan) (5pts)

Write a simple C++ program that prints "Hello, World!" (or some other greeting of your choice) on the command-line. No write-up is needed for this orientation lab; the main point is to make sure you are setup with a C++ development environment (editing, compiling, running).

If you are using Microsoft Visual Studio 2008, note that it is a very complex and powerful development environment; invest time to learn it, and it will help you in the long term. Visual Studio is available on the senior lab computers. When it starts up for the first time, select "Visual C++" as the working profile.

You may find helpful Microsoft's "Visual C++ Guided Tour" (also available from online help within Visual Studio). The first section, "Introducing the Visual Studio IDE (C++)", and parts of the second section, "Creating Command-Line Applications (C++)", will be most pertinent to your Win32 command-line application.

Package up your whole project directory, including all source and header files, into one ZIP file, and upload it to myCourses.

Lab 1: Selection (due Wed 21 Jan) (20pts)

Write a C++ program that uses the if or switch structures to print the song, "The Twelve Days of Christmas". The user must be asked to enter a day from 1 to 12, and the program must display the corresponding message for that day. The strings for each day should only appear in your code once each (e.g., the string "five golden rings" should only appear in your code once). Google for the lyrics, or make up your own (keep it clean, please).

Lab 2: File I/O (due Fri 30 Jan) (20pts)

Choose one of the following options:
  1. Write a program that produces a histogram of the letters in a file. A histogram is a bar-chart with the length of the bars representing the frequency with which the corresponding letter appears in the file.
  2. Write a ROT13 encryption program that reads in a plaintext file and outputs encrypted text to another file.
  3. Write a program that gives and takes advice on programming. The program starts by displaying a piece of advice on the screen, then asks the user to type in another piece of advice (can be multiple lines), ending with a blank line (press Return twice). The program then ends. The next person to run the program sees the piece of advice given by the last user to run the program.

Lab 3: OO Class Design (due Fri 13 Feb) (20pts)

Write a class defining some new kind of mathematical entity not built-in to C++. Possible options are mentioned below. Your class must include at least the following functionality: Possible mathematical entities you may consider:
  1. Rational numbers (fraction of two integers). Include a method to reduce the fraction to lowest terms. Be sure to protect against zero denominator.
  2. Complex numbers (a + bi, a real and an imaginary part). Make sure that multiplication works the proper way for complex numbers.
  3. 2x2 matrices. Include a method to compute the determinant. Come up with a reasonable semantics for the operators.
  4. Come up with your own idea! Just check with me first.

Lab 4: FLTK Program (due Wed 4 Mar) (20pts)

Write a "reasonably useful" interactive program using FLTK for the GUI. Your application should be designed to make use of a GUI (i.e., not something that could easily be done in a command-line text interface). You may find the FLTK docs and Erco's FLTK Page helpful. You do not have to use Fluid if you don't want to.

Be creative and have fun!

Lab 5: FLTK Program II (due Wed 18 Mar) (20pts)

Both of these options require a nice user-friendly FLTK GUI: your program should be reasonably easy-to-use and not unbearably ugly. An average computer user (non-programmer) should be able to figure out the controls, even without the help text (which you should also provide). You are not required to use Fluid, but you are asked to use FLTK.

Lab 6: Client/Server Sockets (due Wed 8 Apr) (25pts)

Design a networked client/server application and implement it in C++ using TCP sockets.