Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. I need help with a progra.

I need help with a progra.

Scheduled Pinned Locked Moved C#
helptutorialquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex501
    wrote on last edited by
    #1

    Could someone help me out with this program? Draw the circle on a sheet of paper. Remember how big the paper is (how high & how wide, which gives us the total area), and how big the circle is. 2. Randomly pick points on the paper (say, by throwing darts). For each point we randomly pick, we'll do the following: a. If the point is inside (or on the line of) the circle, we'll increment our counter that keeps track of the number of points that landed inside the circle. b. If the point isn't inside/on the circle, and you need to, and increment another counter to keep track of that. c. Either way, increment your "How many times did I pick a point?" counter d. Darts that fall outside the paper are ignored entirely. Even better would be to find a way to make sure that your randomly selected points never end up outside the paper in the first place. 3. Once you're done throwing all the darts in step 2, figure out what percentage of the darts fell inside the circle. As an example, let's say you threw 1,000 darts, 534 of them landed inside/on the boundary of the circle, and 466 landed outside the circle, but on the paper. Thus, 53.4% of the darts landed in the circle. 4. Figure out how big the sheet of paper is (what the total area is). As a continuing example, let's say that the paper is 100 inches wide, and 200 inches tall, for a total area of (100x200=20,000) 5. Estimate that the area of the circle to be the size of the paper, multiplied by the percentage of points that were inside the circle. As a continuing example, we'll estimate that the size of the circle is 53.4% of 20,000, or (20,000 * .534=) 10,680 square inches. The downside is that this is computationally intensive (i.e., you can't really do this by hand). The upside is that this works for *ANY* shape, no matter how complicated. For this homework assignment, we'll stick with circles, and only circles. Your task is to write a program that will demonstrate how accurate this method is, depending on how many points you randomly select. Basically, you're going to go through, and use the Monte Carlo method to estimate the area of the circle, then use the real formula to find the actual area, then compare the two. The 'error' here will be measured as the percentage difference between the estimated & real circle (so if the circle is 314 units in size, and the estimate is 0, then the error is -100%, meaning that we're 100% below the real size. If the estimate is 345.4 uni

    M 1 Reply Last reply
    0
    • A Alex501

      Could someone help me out with this program? Draw the circle on a sheet of paper. Remember how big the paper is (how high & how wide, which gives us the total area), and how big the circle is. 2. Randomly pick points on the paper (say, by throwing darts). For each point we randomly pick, we'll do the following: a. If the point is inside (or on the line of) the circle, we'll increment our counter that keeps track of the number of points that landed inside the circle. b. If the point isn't inside/on the circle, and you need to, and increment another counter to keep track of that. c. Either way, increment your "How many times did I pick a point?" counter d. Darts that fall outside the paper are ignored entirely. Even better would be to find a way to make sure that your randomly selected points never end up outside the paper in the first place. 3. Once you're done throwing all the darts in step 2, figure out what percentage of the darts fell inside the circle. As an example, let's say you threw 1,000 darts, 534 of them landed inside/on the boundary of the circle, and 466 landed outside the circle, but on the paper. Thus, 53.4% of the darts landed in the circle. 4. Figure out how big the sheet of paper is (what the total area is). As a continuing example, let's say that the paper is 100 inches wide, and 200 inches tall, for a total area of (100x200=20,000) 5. Estimate that the area of the circle to be the size of the paper, multiplied by the percentage of points that were inside the circle. As a continuing example, we'll estimate that the size of the circle is 53.4% of 20,000, or (20,000 * .534=) 10,680 square inches. The downside is that this is computationally intensive (i.e., you can't really do this by hand). The upside is that this works for *ANY* shape, no matter how complicated. For this homework assignment, we'll stick with circles, and only circles. Your task is to write a program that will demonstrate how accurate this method is, depending on how many points you randomly select. Basically, you're going to go through, and use the Monte Carlo method to estimate the area of the circle, then use the real formula to find the actual area, then compare the two. The 'error' here will be measured as the percentage difference between the estimated & real circle (so if the circle is 314 units in size, and the estimate is 0, then the error is -100%, meaning that we're 100% below the real size. If the estimate is 345.4 uni

      M Offline
      M Offline
      Mark Churchill
      wrote on last edited by
      #2

      Can you post your teachers email? We might have some questions to ask...

      Mark Churchill Director Dunn & Churchill Free Download:
      Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio.

      N 1 Reply Last reply
      0
      • M Mark Churchill

        Can you post your teachers email? We might have some questions to ask...

        Mark Churchill Director Dunn & Churchill Free Download:
        Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio.

        N Offline
        N Offline
        N a v a n e e t h
        wrote on last edited by
        #3

        Mark Churchill wrote:

        Can you post your teachers email?

        :) BTW, I have downloaded Diamond Binding from your site. Honestly speaking it is the best one. But I haven't seen a method to use Stored Procedures as we did in LINQ.

        All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

        M 1 Reply Last reply
        0
        • N N a v a n e e t h

          Mark Churchill wrote:

          Can you post your teachers email?

          :) BTW, I have downloaded Diamond Binding from your site. Honestly speaking it is the best one. But I haven't seen a method to use Stored Procedures as we did in LINQ.

          All C# applications should call Application.Quit(); in the beginning to avoid any .NET problems.- Unclyclopedia My Website | Ask smart questions

          M Offline
          M Offline
          Mark Churchill
          wrote on last edited by
          #4

          Thanks :) Glad you like it! The basic answer is that we don't support object persistance through stored procs. The long answer is that we don't think it is necessary for a few reasons. Diamond Binding queries the database differently depending on what you are doing - say you are retrieving a Customer record, it may choose to bring back the Address object that Customer.Address references in one query by joining the table on. Additionally the query API (FindByProperty, etc) will obviously generate different queries. CRUD stored procedures would be less flexible and lead to worse performance for the query strategies that Diamond Binding uses. Generally speaking we provide a level of abstraction from the database so you don't have to worry about the query mechanics - as it says on the tin, we take over between the database and the domain objects :)

          Mark Churchill Director Dunn & Churchill Free Download:
          Diamond Binding: The simple, powerful, reliable, and effective data layer toolkit for Visual Studio.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups