Solved CSC150 Computer Science Programming Assignment 4 Decisions

$30.00

Original Work ?

Download Details:

  • Name: P4-150-Diceroll-Game-qwrnqh.zip
  • Type: zip
  • Size: 949.53 KB

Category: Tags: , You will Instantly receive a download link upon Payment||Click Original Work Button for Custom work

Description

5/5 - (1 vote)

Dice Roll Game

 Write a program to implement a dice game.  The game is played as follows:

  1. The Computer rolls 2 dice
  2. The user rolls 2 dice
  3. The following rules determine the winner
    1. Closest to 12 wins
    2. Lucky 7 (sum of 7) beats closest to 12
    3. Snake eyes beat Lucky 7.
  4. First Snake Eyes, then Lucky 7, then closest to 12

 

You can get the computer and user’s dice rolls in main, but you must use separate functions to:

  1. Determine the winner
  2. Print the results

 

Use the random number generator to get the dice rolls.  Seed the generator once in main, use successive calls to rand to get random numbers, then mod by 6 and add 1 to scale them to be in the range 1 through 6.

Use constants for User, Computer, or Tie, storing the correct one into a winner variable that is returned from your determine winner function and passed into your print results function.

 

Design your program by completing the CSC 150 Program Design Document.  Be sure to include a structure chart for the program, the prototype for each function, and a brief description of each function’s purpose.  Save the design in a file named GameDesign_xxx.doc where xxx are your initials and submit it in the Program 4 Design drop box by the date shown in the calendar and drop box tools – this is before the program due date.

 

Code your program.  Save it in a file named game_xxx.cpp where xxx are your initials.

 

Compile, run and test your program.

 

Submit your working .c file in the Program 4 drop box by the due date shown in the calendar and drop box tools.

 

In the final program, we will seed the rand function with a random number srand(Time (NULL))

 

Include time.h, stdlib.h and stdio.h

 

For the number answers, you can mod by 12 to give a number between 0 – 11

You can shift it up by adding 1 to it which gives 1-12

 

Use separate function —

 

printf (“%d\n”, ((rand()% 6) + 1));

rand () % range + LOW

 

& and is higher than or ||

 

Add data flows to your structure chart to get extra points