CSCI 201 Fall 2000

Assignment 3

Program 1: Work assignment number 5.4 on page 204 of the text

Write a program called gcds.cpp to perform the task described in problem 5.4. The final version of the program should contain at least 2 functions: 1 function named gcd with two parameters that returns the gcd of its two parameters, and a function called main. The program gcds.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 gcds.cpp.

Program 2: Work problem number 5.6 on page 205 of the text

Write a program called twinprime.cpp to perform the task described in problem 5.6. The final version of the program should contain at least 2 functions: 1 function named prime which should be similar to the prime function discussed in class, and a function called main. The program twinprime.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 twinprime.cpp.

EXTRA CREDIT (10PTS): Work problem number 5.17 on page 207 of the text

Write a program called craps.cpp to perform the task described in problem 5.17. You will need to include both the .h file and the .cpp file 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 after spring break. Oooops, you'll also need the .h file and the .cpp file for 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.17. The program craps.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 craps.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., gcds.cpp, twinprime.cpp and craps.cpp) should be turned in. You were shown how to transfer files to your class ftp directory in lab01, here is a quick repeat.