Physics 222/322 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. Writing your own programs

    Now you will write your own programs similar to "convert". Write programs in C++ and Fortran that takes an input area in square meters, then it converts and prints the equivalent area separately in the following units: square feet, acres, hectares, and barns. To begin with declare the numerical variables as "integer"s in Fortran or "int"s in C++.

    1. Run your program with the following input areas: 5, -50, 50000, 5555.5, and 6.59374E-27 . As in the other problem copy and paste these results into your solution. Do you see any problem with these results? What is happening?

  2. Alter your own program

    Now change the variable declarations in your code so that all numerical variables are declared with "float" in instead of "int" C++ and "real" instead of "integer" in Fortran. Also, make sure that any numerical constants that you use include a decimal point (i.e. 99 => 99. or 99.0). Re-run the same input areas as above and copy the results into your solution.

    1. What has changed? Do you results now match what you expect?
  3. Answer the following Chapter Review questions from chapter 2 in your testbook:

    3, 5, and 8.