Program3 - /Item Points Possible Actual Points/Pasting this...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
//********************************************************************************* ********************************************** //Item Points Possible Actual Points P //Pasting this table in your writeup 1 1 //Your name 1 //Description 1 //Function Comments 7 //(parameters, pre/post conditions, //descriptions) / //Use of functions 4 //Main function 4 //Computer Turn function 7 //Human Turn function 3 //Detects winners 2 //********************************************************************************* ********************************************** //Tom Nanke //CIS150-001 //10/30/07 //Program 3 //This program plays the game of pig. This is a game in which two players take turns rolling a six-sided die and the first player //to reach 100 points wins. In this game, however, the two players are a human player and a computer player. The //human player takes the first roll, and if he/she rolls from 2-6, he/she can choose to roll again or hold. If he/she decides to //hold, then the sum of all the rolls from the current turn is stored into his/her total score of the game. If a 1 is rolled, //however, the user's turn ends and no new points are added to his/her total game score. Once the user's turn is over, either //because of a hold or a 1 is rolled, then it becomes the computer's turn. To start, the computer keeps rolling a die until it //either rolls a 1 or gets a total sum of 20 or more, in which case it then holds. Then it would once again become the user's //turn, and after his/her turn, the computer keeps trying to roll until it reaches a 100, going back to last held value if it //rolls a one. The expected input is the user's selection of whether to roll or hold. The expected output is the total scores //at each turn, and then the winner of the game. //********************************************************************************* ********************************************** * #include <iostream> #include <ctime> //Here I include both ctime and time.h so that I get generate different random numbers for the human #include <time.h> //roll and for the computer roll. /
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/25/2010 for the course CECS CIS 150 taught by Professor L.tsui during the Fall '07 term at University of Michigan-Dearborn.

Page1 / 5

Program3 - /Item Points Possible Actual Points/Pasting this...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online