Section 0101, 0102, 0103 and Honors, Fall 1995

Project 1

Due: Wednesday, September 27, 1995


Objective

The main objective of this assignment is to make sure that everyone has learned enough about C and the UNIX system to write a simple program with a loop, compile it, run it and turn in the program.

Assignment

Your assignment is to write a program to play the game of craps. Craps is a casino game where the player (called the shooter) throws two six-sided dice. The outcome of the game depends on the results of several throws. According to Encyclopedia Britannica, the rules for craps are as follows:

If the shooter throws a 7 or 11 (natural) on his first roll, he wins; if he rolls 2, 3, or 12 (craps) on the first roll, he loses... If the shooter's first throw is 4, 5, 6, 8, 9 or 10, that number is his point, and he continues to throw until he rolls the same number again (makes his point) and wins or throws 7 (misses out, or craps out) and loses.

For example, if the player's first throw is 6, he will roll the dice again and again until either 6 or 7 is rolled. If he rolls 6 he wins; 7 he loses.

Your program will help the shooter keep track of the game. Your program should ask the shooter to enter the result of each throw. You may assume that the shooter always enters a legal number between 2 and 12. After each entry, your program should tell the shooter if he/she has won the game, lost the game or should roll the dice again.

Turning in your program

When you are sure that your program is properly documented and that it is working correctly and assuming that you already have a directory called bin in your account, you should use the following command to copy the mail2chang command to your account:

   % cp ~chang/pub/cs201/mail2chang ~/bin/
Then you can turn in your project using the mail2chang command. The program will ask you for a project number (1 in this case) and the name of the file that has your project. When the program asks you for an output file, answer none (for this project only). The mail2chang program simply mails your project to the e-mail address chang@gl.umbc.edu. You will get an e-mail message that your project was received. The response is automatically generated and may take as long as an hour to get to you (usually it takes 5 minutes). A copy of your submission is included in the reply, so you can double check that you sent the correct file by checking the reply.

Please do not use any other program (e.g., elm, pine, submit, etc.) to turn in your project.


Late Policy Reminder

This project is due by midnight on Wednesday, September 27, 1995. We will use the system clock as the final arbiter of time and date. If you turn in your project after the due date, a 4% penalty will be assessed. The penalty doubles every 24 hour period, including the weekend. For example, if you turn in the project on Saturday, September 30, a 16% penalty will be assessed.

Optional Embellishments

If you wish, you can embellish your program by making sure that the shooter does not enter an illegal dice roll. If the shooter enters 13, for example, your program can prompt the shooter to enter a legal value.


Sample Run

The following is a sample run of one version of the project. Your program should behave in a similar manner, but it does not have to be identical to this one.

lassie% a.out
Ready for a game of craps.
Enter the first throw: 7
You win!!!

lassie% a.out
Ready for a game of craps.
Enter the first throw: 11
A natural! You win!!!

lassie% a.out
Ready for a game of craps.
Enter the first throw: 12
Craps, you lose

lassie% a.out 
Ready for a game of craps.
Enter the first throw: 2
Oh well, you lose

lassie% a.out
Ready for a game of craps.
Enter the first throw: 6
Roll again and enter the throw: 8
Roll again and enter the throw: 9
Roll again and enter the throw: 12
Roll again and enter the throw: 3
Roll again and enter the throw: 2
Roll again and enter the throw: 6
You made your point! You win!!!

lassie% a.out
Ready for a game of craps.
Enter the first throw: 5
Roll again and enter the throw: 4
Roll again and enter the throw: 6
Roll again and enter the throw: 6
Roll again and enter the throw: 7
You crapped out, you lose
 

Last Modified: Mon Sep 18 23:52:10 EDT 1995

Richard Chang, chang@gl.umbc.edu