Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please code in c++ ---------------------------------------- In Dungeons & Dragons , and similar role-playing games, dice with different numbers of sides are used to determine the

please code in c++

----------------------------------------

In "Dungeons & Dragons", and similar role-playing games, dice with different numbers of sides are used to determine the outcomes of events throughout the game.

There are different dice for different occasions: 4-sided, 6-, 8-, 10-, 12-, and 20-sided dice are common.

A required roll is typically designated d where is the number of dice to throw and is the number of sides on those dice. For example, 2d6 means throw two 6-sided dice and add the results, and 1d12 means throw one 12-sided die.

This lab requires you to write a program to read in the number of sides on the dice to throw, and then simulate throwing two of them and summing the result, three times in total.

For example, a program run might look like this:

Number of sides (4, 6, 8, 10, 12, or 20): 6 2d6 result: 3 + 2 = 5 2d6 result: 5 + 4 = 9 2d6 result: 2 + 2 = 4 

Hints:

1) Read the input into an integer variable.

2) Do NOT change the seed in the srand() call from the starter code; it is required for the test runs to generate predictable results.

3) An N sided die should return results in the range 1..N.

4) You might want to review the documentation on rand().

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Repairing And Querying Databases Under Aggregate Constraints

Authors: Sergio Flesca ,Filippo Furfaro ,Francesco Parisi

2011th Edition

146141640X, 978-1461416401

More Books

Students also viewed these Databases questions