Due Date: Wednesday of week 02

The following guidelines are expected for all homework submissions:

Problems for Assignment #1

Learning Outcomes: 1) make sure your Java Development Environment is working; 2) make sure your GitHub repo is set up and accessible; 3) make sure you can check code into your repo

This assignment is actually really easy. All you need to do is:

  1. Find a partner to work with
  2. Get your GitHub accounts set up for the two of you
  3. Get your GitHub repository set up on one person's account; invite the other person to collaborate
  4. Create your repository with all the required folders; use the empty file README.md to start the folders [GitHub won't let you create just an empty folder ~ you need something in it]
  5. Make sure that the folder structure is set up the same as on the week one page under the Assignment Submissions section
  6. Make sure that both team members have access to the repo and can commit to it without errors
  7. Make sure that the repository is PRIVATE for reasons explained in class
  8. Invite your professor to participate in your repository; my GitHub name is bjohnson05 and my squirrel drinking coffee logo should be visible
  9. Be sure to check that your code runs from the command line, the REAL one, not one that is part of an editor or IDE like Eclipse or VScode
  10. Commit one copy of your week one in-class exercise to your homework01 directory

For an extra challenge:

One easy way to determine the approximate value of PI is to use what's known as the Monte Carlo simulation. To do this, implement the following steps:

  1. Imagine a unit circle which is a circle with a radius of one
  2. Inscribe that circle inside a square, so that the four sides of the square are tangent to the circle on four sides; this means you have a square that is 2 units by two units with the circle inside it
  3. Now imagine throwing a large bunch of darts that RANDOMLY land inside the square; some will land in the circle, some will land in the square OUTSIDE the circle
  4. Given the area of the square is Ar = 2 * 2 = 4 units
  5. Given the area of the circle is Ac = PI * r * r and since r = 1, Ac = PI units
  6. Taking the ratio of Ar to Ac give the equation Ar / Ac = 4 / PI
  7. Rearranging that equation gives PI = (Ac * 4) / Ar
  8. OK, now we can create a program for this! See if you can write a program in Java that will give an approximate value of PI using Monte Carlo Simulation. The steps are as follows:
    1. Generate a large number of random X and Y paired values to simulate points where darts hit
    2. Count how many total points there are to simulate the area of the square
    3. Calculate the distance of each point from the center [origin] of the circle; if it is less than or equal to one, that dart is INSIDE the circle so count it
    4. When all darts are thrown, use the total number thrown as Ar and the total count INSIDE the circle as Ac
    5. Calculate and output the approximate value of PI using the equation developed above