Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with coding this C++ Only. Should go in order as in the second picture that the starter code. Need to be inorder 3.11

image text in transcribedimage text in transcribed

Need help with coding this

C++ Only. Should go in order as in the second picture that the starter code. Need to be inorder

3.11 Assignment Part 2: Dice Roll Redux 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 where is the number of dice to throw and is the number of sides on those dice. For example, 2do 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 such a designation, and then simulate throwing the appropriate dice, summing and displaying the result, three times in total. NOTE: use the random number seed 1701, so that the test results will match when the program is implemented correctly. We will simplify this a little by only dealing with 6, 10, 12 and 20 sided dice, and only allowing the user to specify 1-3 dice to be thrown. For example, a program run might look like this: Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '2d6'): 3010 3d10 result: 8 + 9 + 9 = 26 3d10 result: 9 + 9 + 9 = 27 3d10 result: 5 + 1 + 9 = 15 The input should be validated, so if the number of dice is not 1,2, or 3, or if the middle character is not 'd', or if the number of sides is not 6, 10, 12, or 20, the program should report the error: Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '2d6'): 4x9 Not a valid designation Hints 1) Read the number of dice into an integer variable. 2) Read in (consume) the d character. 3) Read the number of sides into an integer variable. 4) An N sided die should return results in the range 1..N. 5) You might want to review the documentation on rando. 6) Do not roll more dice than specified, or it will change your random number sequence. #include #include using namespace std; ; int main() { // TODO (1): Initialize random number generator with correct SEED // TODO (2): Declare variables // TODO (3): Prompt user for designation, and read input // TODO (4): Validate input // TODO (5): If Not valid ... output error message // ... else ... // TODO (6) Generate and print the result of roll one // TODO (7) Generate and print the result of roll two // TODO (8) Generate and print the result of roll three return 0<><>

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

Data Visualization A Practical Introduction

Authors: Kieran Healy

1st Edition

0691181624, 978-0691181622

More Books

Students also viewed these Databases questions