- Welcome back, how did you make out…with that last challenge?…Well, I hope you had some success.…I'd like to go over my solution,…and as always remember, it might be different than yours.…I have my Monte Carlo simulation set up…to go through three different trials.…One, with a 100 attempts, one with a 1000,…and one with 10,000.…Let's take a look at the actual Monte Carlo code itself.…As you can see, I pass in the numTrials…to the method marbleSimulation.…On lines 28 and 29 I declare two static variables,…one to represent the blue marbles has a value of 1,…and a second variable to represent the white marbles…which will hold a value of 2.…
On lines 31 and 32 I have two variables,…double number record the number of successes,…the number of times all three marbles are the same color.…Double result will be the value…that takes the number of successes divided by the numTrials.…Starting on line 54 is my simulation loop.…I'm gonna scroll down a little bit.…Line 36 I add one to my total attempts,…then I declare on line 38 my bowl…
- Getting started with parsing
- Reviewing data types
- Using decisions
- Creating user-defined methods
- Command-line debugging
- Exploring the Java API
- Creating and instantiating classes
- Working with interfaces
- Storing items with arrays
Skill Level Intermediate
Q: How can I make my debugger function like the author’s?
1. Command Level Programming
2. Basics Review
4. Java API
5. Simulations and Algorithm Analysis
6. Classes and Objects
7. More on Classes
8. Data Structures
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.