Example Solution:

Monte Carlo Integration Assignment

(Console version)

  1. The provided files are (obviously) C#, and (less obviously:) ) they were built using the Visual Studio 2005 product. If you have an older version of Visual Studio (or are using Mono), you probaby won't be able to open the Solution (.SLN) file. If this is the case, in order to build this, you'll need to add all the .CS files to a new project, and then everything should compile & run just fine.
    1. Other than the System.Random, and System.Console classes, this program uses no other classes, so this *should* be good to go on VS 2003, and Mono ; it hasn't been tested on those systems, though.
  2. The assignment focuses on arrays, and procedural decomposition. This being C#, seeing some classes is pretty inevitable, and even if instructors aren't teaching about OOP specifically, it's pretty much assumed that students have seen enough to be able to follow a pattern (such as having main instantiate an object & call RunProgram on it, and then having all the 'procedural' logic on the other class).
    1. In order to avoid any OOP material, this solution specifically avoids the use of instance variables, even when it might make sense.
    2. As the instrutor, one might hand out a 'starter project' to students, with the "Main" class, and the MonteCarloIntegrator class, and thus allow for functional decomposition, without having to cover the OOP stuff first.