Physics 222 Assignment 2

Due January 31

Directions

Please turn in this assignment (and all future assignments for this course) by emailing them to me . Please use the subject of "Physics 222 HW2" for these assignments (if you use the link above, the subject will be added automatically). Please attach the any source code to programs that you write for this assignment. If you write more than one program, attach each separately. When answering the questions themselves feel free to answer directly in the body of your message (or attach your answers). I may take off points for assignments that are not sent to me in the correct form.

  1. Finding Pi

    Write a program to find the value of π. There are many possible methods for doing this, but the simplest is probably to use inverse trig functions and your knowledge of them. These functions take in numerical values and return angles in radians.

    1. Find results for π using three different bit sizes for your variables. Copy and paste these results into your assignment.
    2. How well do these results match with the expected value of π? To how many digits do they match? Can you explain any discrepancies?
  2. Scales

    As an intern at a company that makes custom scales, you are assigned the job of writing a program that makes price quotes for customers interested in buying a scale. There are several factors that go into pricing your scales. There is a $20 base charge for any scale. Then there is charge for the spring, which is based on the maximum weight that your customers want the scale to be able to read. Your company prices the springs at $15 times the square root of the maximum weight in N. Of course your customers are mostly Americans, so you need to ask them for the maximum weight in pounds, and your program should do the proper conversions. Finally, you charge customers $100 per m2 of the pan that the object to be weighed is placed on. Here you should prompt the customers for the length and width for the pan in feet, and do the proper conversions in your program.

    You should run your program with the following sets of input, and include the results in your assignment.

    Max weight Length Width
    (lbs)(ft)(ft)
    100.02.51.0
    15.0 0.333330.5
    2000.06.06.0
    1.00.250.166667
    50000.010.08.0

    To make it easier to debug your program, I would like to you to output the results of any conversions that your program does, as well as how each piece of data adds to the total price of the scale.