CSCI 201 Spring 2001

Assignment 3

Program 1:

Write a program called multiply.cpp that generates (calculates each product), and displays the following multiplication table:

  
   1  2  3  4  5  6  7  8  9  
1  1
2  2  4
3  3  6  9
4  4  8 12 16
5  5 10 15 20 25
6  6 12 18 24 30 36
7  7 14 21 28 35 48 49
8  8 16 24 32 40 45 56 64
9  9 18 27 36 45 54 63 72 81
You will need to use nested loops in writing this program, or, alternatively, you can call a function that prints one row at a time (using a loop) from within the body of a loop that prints the entire table. This was demonstrated in class with the calprint program. The program multiply.cpp must be turned in by transferring it to your ftp directory for this class. Only the source code file should be turned in and it must be named multiply.cpp.

Program 2: Work problem number 5.2 on page 203 of the text

Write a program called totempole.cpp to perform the task described in problem 5.2. You will need to include both the .h file, dice.h, and the .cpp file, dice.cpp, for the dice class in your project folder in order to write this program. Programs using the dice class are presented in your text and will be discussed in class. You'll also need the files randgen.h and randgen.cpp defining the randgen class (i.e., a class used to generate a random number); this class is used by the dice class. Be sure to include both .h files and both .cpp files in the project where you write the code for problem 5.2. The program totempole.cpp must be turned in by transferring it to your ftp directory for this class. Only the source code file should be turned in and it must be named totempole.cpp.

Programming Style

Note that 10% of your program grade is based on the readability of your program. This includes things like style, comments, and the naming of variables and functions. Make sure you include a comment at the top of each program with your name, course and purpose of the program specified.

// Name: YOUR NAME HERE // // Course: CSCI 201 // // Purpose: purpose of program here //

Submitting Programs

As stated above, the programs written for this assignment must be turned in by transferring the C++ source code files to your ftp directory for this class. Only the source code files (i.e., multiply.cpp, and totempole.cpp) should be turned in. You were shown how to transfer files to your class ftp directory in lab01, here is a quick repeat.