Question: (C++) Hello, I need help to write this program(Only C++). Please follow the instudction carefully. I will attach the source code below the instruction. --------------------------------------------------------------------------------------------------------------------
(C++) Hello, I need help to write this program(Only C++). Please follow the instudction carefully.
I will attach the source code below the instruction.



--------------------------------------------------------------------------------------------------------------------
source code
#include#include using namespace std; int* startEndPairs(string s); int main() { srand(time(0)); // DO NOT WRITE THIS LINE AGAIN OR ANYWHERE ELSE cout (s.length()); i++) { if(s[i] == 'd' || s[i] == '+') { parts++; } } // ... so we can make the correct size array to store the info string* data = new string[2*parts]; int index=0; unsigned d = s.find('d'); unsigned p = s.find('+'); while(d != static_cast (-1) || p != static_cast (-1)) { bool dFirst = d (s.length()-d-1); i++) { if(isdigit(s[count+d+1])) { foundDigit=true; } if(!isdigit(s[count+d+1]) && foundDigit) { break; } count++; } string after = s.substr(d+1,count); //should be just the number after 'd' // store these two parts data[index] = before; data[index+1] = after; index+=2; // remove this part from the string s s = s.substr(d+count+1); // discard these two parts } else // same idea for the '+' { // figure out what number is after '+' int count = 0; bool foundDigit=false; for(int i=0; i(s.length()-p-1); i++) { if(isdigit(s[count+p+1])) { foundDigit=true; } if(!isdigit(s[count+p+1]) && foundDigit) { break; } count++; } string after = s.substr(p+1,count); //should be just the number after '+' // store this part data[index] = "+"; data[index+1] = after; index+=2; // remove this part from the string s s = s.substr(p+count+1); // discard these two parts } // update d and p for next loop interation d = s.find('d'); p = s.find('+'); } // now we need to figure out how many dice there are (as 2d4 is 2 dice) // we will treat "+2" as a dice that rolls [2,2] int diceCount = 0; for(int i=0; i Start by downloading the "dice.cpp" file from the webpage. This will come with a small mainO and a function to parse the user input into an array of ranges for dice. The format expected for the user to input is either "xdy", where x and y and integers or "+x" where x is an integer. For example "2d6+1" will represent rolling two 6-sided dice, summing the faces then adding one to the result. Multiple additions or dice can be incorporated by spacing, for example: "2 d 4 + 1 3d6 +4 will be two 4-sided dice, three 6-sided dice plus 5. (Note: a "die" always rolls 1 to the maximum number. So "1d20" or one twenty-sided die will be a random number between 1 to 20.) Your program must have the following (1) Create a Dice class that has 1. Two private integer variables to store the minimum and maximum roll possible 2. Two constructors (a default and a nondefault one that takes two integers for min/max values of rolls) 3. Overload the class with cout to display a random roll of the dice. In your output, you should include the following line in mainO: (it is the first line displayed in the examples after the prompts) cout
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
