1. Include a function called, rollDice( ), which returns two random tosses of the die. Notice the function returns two variables. Important Note: When you call this function you need to have two variables in order to receive both values. Sample: x, y = rollDice( ).
2. Include a function called, determine_win_or_lose(int, int), which receives the two random tosses of the die and returns the results (0 for lose and 1 for win)
3. Include a function called, determinePointValueResult(int), which receives a point value and returns the results (0 for lost, 1 for win).
4. In main, ask the user to input how many games they want to play then simulate playing the game that many times.
5. In main, at the end of playing all of the games print the total number of wins and losses.
PSEUDO CODE:
rollDice( )
Get random number 1-6
Get second random number 1-6
Return both numbers
Determine_win_or_lose(int, int)
Add two random numbers passed to function to get sumPrint appropriate phrase regarding sum of the two numbers
If sum is 2, 3, or 12
Set result to a lost
Else if sum is 7 or 11
Set result to a win
Else Print message indicating it is a point value
Call determinePointValueResult function
If win
set result to a win
else
set result to a lost
return result
DeterminePointValueResult (int)
While sum is not 7 and sum is not point value
Call rollDice function
Add two random numbers returned to get sum
if sum equals point value
set result to a win
else if sum equals 7
set result to a lost
Print appropriate phrase regarding sum of the two numbers
return result
#-----------Main------------------
Set win/lost counters to zero
Ask how many games you want to play
Loop
Call rollDice function
Call determine_win_or_lose function
If win
Add to win counter
Print "You win"
Else
Add to losses counter
Print "You lose"
End Loop
Print Game results
--------------------------------------------------------------------------------------------------------------------------
Sample Output
How many games do you want to play > 6
You rolled 5 + 2 = 7
You win
You rolled 5 + 6 = 11
You win
You rolled 4 + 1 = 5
point is 5
You rolled 4 + 3 = 7
You lose
You rolled 2 + 5 = 7
You win
You rolled 2 + 6 = 8
point is 8
You rolled 2 + 2 = 4
You rolled 4 + 3 = 7
You lose
You rolled 3 + 5 = 8
point is 8
You rolled 1 + 4 = 5
You rolled 4 + 4 = 8
You win
Game results: 4 wins and 2 losses