Purpose: The lab this week will focus on learning how to implement a Monte Carlo simulation using die rolls. The concepts covered in this lab are for loops, file input, and randomness.
Task: This program will need all classes in the io package as well as the Random class. You will use the PrintWriter class to save the results of this lab to a text file. Use the Random class to simulate rolling a die. This means randomly picking a number from 1 to 6. Perform this action 10000 times and maintain a count of how often you roll each side of the die. When printing the results to a file, including both the number of rolls as well as the percentage of rolls out of the 10000 total rolls. As a small bonus, provide a short write up explaining the meaning behind the results of this simulation.
Bonus Task: As a much larger bonus, instead of simulating rolling a die, refer to the following scenario:
Suppose you're on a game show, and you're given the choice of three doors: Behind one door is a car; behind the others, goats. You pick a door, say No. 1, and the host, who knows what's behind the doors, opens another door, say No. 3, which has a goat. He then says to you, "Do you want to pick door No. 2?" Is it to your advantage to switch your choice?
You will simulate this game show 10000 times and keep a count of how often you win before making the switch and how often you win after making the switch. This means that your program must handle the process of selecting a prize door, having a contestant pick a door, revealing a door to the contestant, and switching the contestant’s choice after the reveal. The results printed to the file should include both the counts and percentages for each type of win.
Criteria: Program correctness includes proper and accurate results from the simulation as well as correctly printing the results to a file. Program correctness is worth 50 points. The simulation process requires properly using loops and the Random class. This process is worth 45 points. Descriptive comments explaining the overall program and key elements are 5 points. The write up is worth 10 bonus points. Implementing a simulation of the game show is worth 50 bonus points.
DescriptionIn this final assignment, the students will demonstrate their ability to apply two majorconstructs of the C programming language – Fu
Path finding involves finding a path from A to B. Typically we want the path to have certain properties,such as being the shortest or to avoid going t
Develop a program to emulate a purchase transaction at a retail store. Thisprogram will have two classes, a LineItem class and a Transaction class. Th
1 Project 1 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of
1 Project 2 Introduction - the SeaPort Project series For this set of projects for the course, we wish to simulate some of the aspects of a number of