complete the function RollSpecificNumber() that takes in three parameters: a GVDie object, an integer representing a desired face number of a die, and an integer representing the goal amount of times to roll the desired face number. The function RollSpecificNumber() then rolls the die until the desired face number is rolled the goal amount of times and returns the number of rolls required.
Using c++
In main.cpp, complete the function RollSpecificNumber() that takes in three parameters: a GVDie object, an integer representing a desired face number of a die, and an integer representing the goal amount of times to roll the desired face number. The function RollSpecificNumber() then rolls the die until the desired face number is rolled the goal amount of times and returns the number of rolls required.
Note: For testing purposes, the GVDie objects are created in the main() function using a pseudo-random number generator with a fixed seed value. The program used during development uses a seed value of 15, but when submitted, different seed values will be used for each test case. Refer to the textbook section on random numbers to learn more about pseudo-random numbers.
Ex: If the GVDie objects are created with a seed value of 15 and the input of the program is:
3 20the output is:
It took 140 rolls to get a "3" 20 times.#include <iostream>
#include "GVDie.h"
using namespace std;
int RollSpecificNumber(GVDie die, int num, int goal) {
/* Type your code here */
}
int main() {
GVDie die = GVDie();
die.SetSeed(15); // Create a GVDie object with seed value 15
int num;
int goal;
int rolls;
cin >> num;
cin >> goal;
rolls = RollSpecificNumber(die, num, goal); // Should return the number of rolls
cout << "It took " << rolls << " rolls to get a \"" << num << "\" " << goal << " times." << endl;
return 0;
}

Trending now
This is a popular solution!
Step by step
Solved in 4 steps









