Using C++ Language Use cout statements to display a 3-dimensional figure of the cube (consider using the characters “-\|/_”) when the program starts up to show the numbering of the corners. The cube corners are labeled from 0 to 7 with 0 starting at the upper left-hand corner of the front face of the cube proceeding clockwise with corners 0, 1, 2, and 3 on the front face, and corner 4 being the upper left-hand corner of the rear face and proceeding clockwise with corners 4, 5, 6, and 7 on the rear face. (Note that computer scientists generally start counting at zero, rather than one, as the math calculations work out better. This will make more sense once we study 2 dimensional arrays.) You will need a delay function to slow down your code so the user can see Herman moving around the cube. You might want to get the following code working in a separate test project and then figure out how to use it in your Herman solution (see below) For each simulation, use cout statements to display the initial corner Herman is randomly placed upon, and the location of the randomly placed poison; use the build in rand function to generate a random integer between 0 and 7. Then using a single output line and a .25 second delay, use cout statements to indicate the corners Herman visits until inevitably reaching the corner with the poison. Then display the total number of corners visited by Herman in that trial and a running average of the number of corners Herman reached in all trials since the program with initiated. When 10 trials have occurred, display Herman The Fly’s expected value. You will need to call or invoke four built-in functions (ctime, srand, rand, sleep_for) and write and invoke at least 7 functions you write yourself as indicated in the structure chart provided below. You must at least create and use these functions to implement your Herman the Fly simulation. While your final solution needs to use srand and ctime to generate a random start seed, I suggest using a fixed seed to run your simulations during implementation, so you have consistent results during debugging.
- Using C++ Language
- Use cout statements to display a 3-dimensional figure of the cube (consider using the characters “-\|/_”) when the program starts up to show the numbering of the corners. The cube corners are labeled from 0 to 7 with 0 starting at the upper left-hand corner of the front face of the cube proceeding clockwise with corners 0, 1, 2, and 3 on the front face, and corner 4 being the upper left-hand corner of the rear face and proceeding clockwise with corners 4, 5, 6, and 7 on the rear face. (Note that computer scientists generally start counting at zero, rather than one, as the math calculations work out better. This will make more sense once we study 2 dimensional arrays.)
You will need a delay function to slow down your code so the user can see Herman moving around the cube. You might want to get the following code working in a separate test project and then figure out how to use it in your Herman solution (see below)
For each simulation, use cout statements to display the initial corner Herman is randomly placed upon, and the location of the randomly placed poison; use the build in rand function to generate a random integer between 0 and 7. Then using a single output line and a .25 second delay, use cout statements to indicate the corners Herman visits until inevitably reaching the corner with the poison. Then display the total number of corners visited by Herman in that trial and a running average of the number of corners Herman reached in all trials since the program with initiated. When 10 trials have occurred, display Herman The Fly’s expected value.
- You will need to call or invoke four built-in functions (ctime, srand, rand, sleep_for) and write and invoke at least 7 functions you write yourself as indicated in the structure chart provided below. You must at least create and use these functions to implement your Herman the Fly simulation. While your final solution needs to use srand and ctime to generate a random start seed, I suggest using a fixed seed to run your simulations during implementation, so you have consistent results during debugging.
Trending now
This is a popular solution!
Step by step
Solved in 3 steps