Ullu utt valeu (tile Welcome sheet and Simulation\" sheet should not be visible)
ID: 3581904 • Letter: U
Question
Ullu utt valeu (tile Welcome sheet and Simulation" sheet should not be visible) Problem 2: Simulation Darts (50 pts) You will simulate a very basic dart game on a sheet named "Simulation". Assume that a dart board is mounted on a 1ft x 1ft square section of the wall. The dartboard has a diameter of exactly 1ft. Assume you and your friends are good enough to always AT LEAST hit within the 1ftx 1ft square (even if you miss the dartboard). However, other than that, your dart throws 1ft are random. Simulate N numbers of throws where N is provided by the user by generating a random value for the x and y coordinates of where each dart throw hits the area. The center of the board should be position x 0 and y 0. The upper right corner of the square is then obviously x 0.5 and y 0.5 and the lower left corner of the square is x -0.5 and y -0.5. If the distance from the center of the dart board is: less than or equal to 0.08 ft then it is considered a bullseye greater than o.08 ft, but less than o.20 ft, it is considered a good shot far enough that it misses the dartboard completely, this is a bad shot
Explanation / Answer
#include #include #include #include #include using namespace std; int main() { const double PI = 3.141592653589793; static double x_cor = 0; static double y_cor = 0; static double x_sum = 0; static double y_sum = 0; double x_y_total = 0; long int num_darts = 0; long int num_hits = 0; long int num_misses = 0; long double pi_approx = 0; srand(time(0)); while ( num_darts != 0 ) // Start of while loop { cout > num_darts; coutRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.