Starting from:

$34.99

780B Problem Set 2-Dice Rolling & Collisions Solution

COMPUTATION

Problem Set 2: Dice Rolling & Collisions

PS2-1 Dice Rolling Monte Carlo

A Monte Carlo Simulation involves the repeated use of random sampling to obtain quantifiable results of stochastic events. In particular, Monte Carlo methods allow for the inclusion of probability distributions for coupled and uncoupled events, thus making it possible to quantify systems whose exact behavior is not clearly understood. Often, Monte Carlo methods reveal that systems that appear random can have predictable behavior in the long run.
For this assignment, we are modeling a simple two-event problem to numerically quantify the results of rolling two dice. Each die has 6 faces, numbered 1 to 6 and each face is just as likely as any other to land on top when rolling. The result of each roll is the sum of the numbers on top of both dice (i.e., minimum 2, maximum 12). The two dice are independent events since the probability of one die’s results is not affected by the other.
You are asked to write a program that asks the user to input the number of rolls they want to model and then perform the simulation while keeping a count of the results (e.g., how many times was a nine rolled?). Then, the program outputs the aggregated results of the simulation, which must include some sort of visualization. Since we have not done graphics yet, the visualization is limited to text.
Hint: What data structure can be used to store the count of all rolls as the simulation progresses?
Sample output (feel free to “make it your own”):
============ DICE ROLLING ============== Enter number of rolls > 50

Results (each '*' represents 1%):
2: ******
3: **
4: ************
5: ****************
6: ********
7: ************************** 8: **************
9: **
10: ******
11: ******
12: **

PS2-2 Collision Problem Quiz (60 pts)
Write a program that randomly creates a unique collision problem of the type shown in the attached example. Allow your program to generate reasonable random values for the problem parameters (masses, velocities, direction angles, coefficient of restitution, etc.). Then, present your problem to the user and ask for the resulting final velocities. Assume that the user has access to the following diagram showing all parameter labels and directions:


Where:
• Disc A has mass massA and is traveling at velocity velA1, at an angle thetaA1 from the x-axis (which is perpendicular to plane of impact and passes through the centers of the discs).
• Disc B has a mass massB and is traveling at velocity velB1, at an angle thetaB1 from the x-axis • The collision has a coefficient of restitution of value eRes.

Let the value of the masses be a uniformly distributed random number varying from 0.5 to 4 kg, rounded to one decimal place. Similarly, let the angles vary from -60 to 60 degrees, rounded to zero decimal places, the velocities vary from 0 to 5 m/s, rounded to one decimal place, and the coefficient of restitution vary from 0.6 to 0.9, rounded to two decimal places.

Your program should ask the user to enter each of the 4 answers (i.e., velAx2, velAy2, velBx2, and velBy2) and determine if the answers are correct (perhaps also providing a measure of error as compared to correct answer). Use the attached sample problem to get a feel for how to use dynamics to work through the solution. You can also “hard wire” the inputs from the sample problem to test the accuracy of your program.

If you feel that your dynamics/physics background is limited enough to make the non-programming part of this problem too much to bear, let me know and we’ll go over it step by step. It all comes down to working with systems of equations.

Deliverables
2 files, very appropriately named:
ps02_dice_yourAndrewID.cpp ps02_collision_yourAndrewID.cpp

Learning Objectives
Developing simple algorithms
Making use of console input/output
Using functions effectively
Searching references (online and/or textbook) for C++ library functions.



More products