Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hi, I need help to finish my C++ code, and I'm having issues Input 2412 Your output 2dL2:22uit Expected output 7:1d12A 041 Output differs. See

Hi, I need help to finish my C++ code, and I'm having issues

image text in transcribedimage text in transcribed

Input 2412 Your output 2dL2:22uit Expected output 7:1d12A 041 Output differs. See highlights below. Input 1412 Your output Expected output 141 Input 3420 Ente= -d20 Your output 9:2d10 041 Output differs. See highlights below. Input 2410 our output2410 Expected output 2410 ait 3.1 T ASsighmeht Part 2. Dice Roll Redux n "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 designatednds> where is the number of dice to throw and s 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 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): 3d10 3d10 result: 8+99-26 3d10 result: 9+9 927 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<>

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

Practical Azure SQL Database For Modern Developers Building Applications In The Microsoft Cloud

Authors: Davide Mauri, Silvano Coriani, Anna Hoffma, Sanjay Mishra, Jovan Popovic

1st Edition

1484263693, 978-1484263693

More Books

Students also viewed these Databases questions

Question

Define self-esteem and discuss its impact on your life.

Answered: 1 week ago