CSCE 2004 - Homework 5
Due Date - 10/18/2012 at 11:59 PM

1. Problem Statement:

The objective of this programming assignment is to become familiar with C++ functions and methods for problem decomposition. You will be modifying a program to fill in the missing code. Here is a link to the code that you will modify: hw5.cpp

In the provided cpp file the main function is already complete. There are function calls in the main function that have been commented out so that the code compiles as-is. It is your job to write these functions so that when you uncomment the function calls in main, the program works correctly.

The objective is to create a simple dice game. When the game starts, the player has 1000 total points. The player starts by wagering a number of points. Then a pair of dice is rolled. If the total of the face values of the dice add up to more than seven or the face values are equal, then the player wins. Otherwise the player loses. For example, if a 1 and 1 is rolled, the player wins. If a 4 and 5 is rolled the player wins. However, if a 1 and 2 is rolled the player loses. A winning roll will add the wager to the total points. A losing roll causes the player to lose the wager, subtracting the wager from the total points.

2. Design

Think about how the functions are being called in your main() function, how the parameters need to be passed to the functions, the type of parameters that are being used and how values are being returned. The main program is included though the function calls are commented out. Other than uncommenting the function calls, you should not have to edit the main function.

You just need to create the functions that main is calling. Above the main function there are comment blocks that should go above each of the functions that you create. Please fill in these comment blocks appropriately.

3. Implementation

To work incrementally, implement one function at a time. For example, the first function being called in main is ShowHomeScreen. Start by creating a function above main called ShowHomeScreen. Once you have created the function, uncomment the first function call to ShowHomeScreen in main. Do this even if the body of your ShowHomeScreen function is not complete. Try to compile the code. If you have the correct function definition, the code should compile. Now when you run you code, main will call your ShowHomeScreen function. Debug this function until you have it working correctly, then move on to the next function.

Once you have all of the functions working. You should be able to uncomment all of the function calls in main and have a working dice game.

4. Testing

Test your program to check that it operates correctly for all of the requirements listed above. Also check for the error handling capabilities of the code. Try your program on 2-3 inputs, and save your testing output for submission on the program due date. Make sure to include valid input and invalid input. (e.g. wagering more than total points should not be allowed)

5. Documentation

When you have completed your C++ program, write a short report (less than one page long) describing what the objectives were, what you did, and the status of the program. Does it work properly for all test cases? Are there any known problems? Save this report in a separate text file to be submitted electronically.

6. Project Submission

In this class, we will be using electronic project submission to make sure that all students hand their programming projects and labs on time, and to perform automatic analysis of all programs that are submitted. When you have completed the tasks above go to the class web site to "upload" your documentation and testing document (pdf, doc, or txt file), and your C++ program (cpp or txt file).

The dates on your electronic submission will be used to verify that you met the due date above. All late projects will receive reduced credit:

You will receive partial credit for all programs that compile even if they do not meet all program requirements, so handing projects in on time is highly recommended.