Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

My code is c++ programming can you guys help me and fix my mistake? here is my code #include #include #include using namespace std; int

My code is c++ programming

can you guys help me and fix my mistake?

here is my code

#include #include #include

using namespace std;

int main() { // TODO (1): Initialize random number generator with correct SEED srand((unsigned) time(NULL));

// TODO (2): Declare variables int number, side; char d;

// TODO (3): Prompt user for designation, and read input // Hint: input an int, a char, and and int: cin >> ? >> ? >> ? cout > number >> d >> side;

// TODO (4): Validate input if ((number 3) || (d != 'd') || !((side == 6) || (side == 10) || (side == 20) || (side == 20))) { // TODO (5): If NOT valid ... output error message cout

// this can be done with a loop for (int ctr2 = 0; ctr2

image text in transcribed

image text in transcribed

image text in transcribed

.
4:2d6 ~ 011 0/1 Output differs. See highlights below. Input 2d6 Your output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '2d6'): 2d6 result: 2 + 5 = 2d6 result: 5 + 3 = 8 2d6 result: 6 + 5 = 11 Expected output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-3ided) Enter designation (e.g. '2d6'): 2d6 result: 4 + 2d6 result: 4 + 2d6 result: 6 + 4 = 10 = 9 5:3d12 A 0/1 Output differs. See highlights below. Input 3d12 Your output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. 2d6'): Not a valid description Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. 2461): 'sa12 resultat 10 = 15 Expected output 3d12 result: 5 12 + 10 = 27 3d12 result: 9 + 10 + 12 = 31 6: 2012 A 011 0/1 Output differs. See highlights below. Input 2012 Your output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-3ided) Enter designation (e.g. '26'): Not a valid description Expected output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '2d6'): 2012 result: 4 2012 result: 10 + 5 = 15 2012 result: 12 + 10 = 22 7: 1012 A 0/1 Output differs. See highlights below. Input 1d12 Your output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '2d6'): Not a va valid description Expected output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '2d6'): 1d12 result: 4 1812 result: 1 1d12 result: 10 8: 3d20 A 0/1 Output differs. See highlights below. Input 3d20 Your output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '26'): 3020 result: 20 + 20 + 12 = 52 3d20 result: 12 + 9 + 15 = 36 3d20 result: 4 + 1 + 6 = 11 19 Expected output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '26'): 3d20 result: 4 + 5 + 10 = 3d20 result: 9 + 4 + 6 = 19 3d20 result: 9 + 14 + 16 = 39 9:2010 0/1 Output differs. See highlights below. Input 2010 Your output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '2d6'): 2010 result: 10 + 10 = 20 2d10 result: 2 + 2 2010 result: 9 + 5 = 14 Expected output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '2d6'): 2010 result: 4 + 5 = 9 2010 result: 10 + 9 = 19 2d10 result: 4 + 6 = 10 10:3d6 a 0/1 Output differs. See highlights below. Input 306 Your output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-3ided) Enter designation (e.g. '2d6'): 306 result: 6 + 6 + 4 = 16 3d6 result: 4 + 1 + 1 = 6 3d6 result: 6 + 5 + 6 = 17 Expected output Choose 1, 2, or 3 dice (6-, 10-, 12-, or 20-sided) Enter designation (e.g. '2d6'): 306 result: 4 + 1 + 4 = 9 3d6 result: 5 + 6 + = 15 3d6 result: 3 + 4 + 6 = 13

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_2

Step: 3

blur-text-image_step3

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

More Books

Students also viewed these Databases questions

Question

Use of assessments to determine trainees learning styles.

Answered: 1 week ago

Question

7. Discuss the advantages of embedded learning.

Answered: 1 week ago