Physics 222 Assignment 6

Due February 28

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 HW6" for these assignments (if you use the link above, the subject will be added automatically). Please attach the source code to any 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. Mass conversion

    Write a program that can convert masses from kg to eV/c^2, slugs, pounds-mass, and solar masses (mass of the Sun). For this program, define a structure that holds the conversion factor in a double, and the name of the unit being converted to in a string. Use new to allocate an array of the conversion structure that you defined. (Don't forget to free the memory at the end of the program). Initialize that structure to contain the information needed to convert eV/c^2, slugs, pounds-mass, and solar masses.

    Have your program list the possible conversions in a menu from: 0) kg to eV/c^2, up to 3) kg to solar masses. Then ask the user to pick one of those values (0 to 3). Then have them enter a mass in kg.

    Your program should do the calculation of the conversion in a separate function, to which your program should pass the value in kg and the conversion factore. Then it should output the mass in the desired units. Note where you are printing the menu, doing the conversion, and printing the results, you should use values (names and conversion factors) from your array of structures. Test your program to answer the following cases, and attach your results:

    1. 2.1E-15 kg in eV/c^2
    2. 102. kg in slug
    3. 102. kg in pound-mass
    4. 201. kg in pounds-mass
    5. 3.7 E30 kg in solar masses
  2. Review Questions from textbook

    4.12 and 4.15