CS 101 Homework 3 Assigned in Laboratory 3 Due at start of Laboratory 4

Pledge

• This assignment is pledged. You may discuss its content and your approach with anyone, but you must do all your own work. You must create the logic of the solution, type your own code, and compile, execute, and debug your own program. You may not use code developed by anyone else.

Objective

• Continue practicing interactive input and output, and to use the if and if-else constructs. This construct will appear in almost all programs you subsequently develop.

Problem 1

• Redo the BMI program with the added restriction that if either the weight or height are less than or equal to zero, then display an error message rather than computing and displaying the BMI in the specified way. A correct version of the previous program is available after Friday, February 9th. You must hand in a printed copy at the start of the indicated lab.  You may also need to submit your program electronically -- see the class home page for info next week. Your electronic submission must be named hw3bmi.cpp.

Problem 2

• The purpose of this program is to input a frequency value, then to identify what part of the electromagnetic spectrum it belongs and to indicate some devices that may be operating at the indicated frequency range.
• If the input value is negative or zero, only an error message should be generated.
• If instead the value is positive, there should be two outputs. The first output should indicate in what broad part of the electromagnetic spectrum does the frequency value fall. Please use the following table for this classification.  (Note: This table may not display in Netscape 4.xx or lower, but it displays fine in Internet Explorer 5.)
 0   ≤  frequency < 103 Hertz 103 ≤  frequency < 106 KiloHertz 106 ≤  frequency < 109 MegaHertz 109 ≤  frequency< 1012 GigaHertz 1012 ≤ frequency < 1014 TeraHertz frequency ≥ 1014 Photonic energy

• The second output indicates a possible use for that frequency values. You should draw upon the following information
• Voice microphones and electronic musical instruments use frequencies that we classified as Hertz.
• Voice microphones and electronic musical instruments use frequencies that we classified as Kilohertz that are less than 3 KiloHertz. Radios and televisions use frequencies in the other part of KiloHertz range.
• MegaHertz frequencies that are less than 3x108 are also used by radios and televisions. Other MegaHertz frequencies are used by radar, microwave emitters and magnatrons.
• GigaHertz frequencies less than 3x1011 are also used by radar, microwave emitters and magnatrons.
• Other GigaHertz and all TeraHertz frequencies are used by lasers, thermals sights, incandescent and fluorescent lights, and range finders.
Photonic energy frequencies less than 1017 are also used used by lasers, thermals sights, incandescent and fluorescent lights, and range finders.
• Photon energy frequencies greater than or equal to 1017 but less than 1020 are used in x-rays. The only devices that use frequencies higher than 1020  are linear accelerators.
• For more info, go to the site www.getcommstuff.com and look for "electromagnetic spectrum" in the Glossary found there.
• You must hand in a printed copy at the start of the indicated lab.  You may also need to submit your program electronically -- see the class home page for info next week. Your electronic submission must be named hw3fre.cpp.

Notes

• A sample of the desired execution is shown below. Observe the title, warnings about inputs, the nice prompt, and the labeled output. While you do not have to use exactly the phrasing seen below, your output must be of equal or higher quality.
• For your input and output, you must use the standard iostream library. Do not use any console or graphical libraries.
• Once more, remember that all calculations are double-precision floating-point.

Submissions

• We hope to submit this program electronically using the UVa Class Toolkit, but we are awaiting the solution to a technical problem....
Important: Look for news about electronic submission posted on the class Web page early next week, or ask in your lecture.
• Whether or not we do electronic submissions, you must also hand in a printed copy at the start of the your lab section February 15th or 16th.  As with earlier labs, print out your source code, sign the pledge with your handwritten signature near where you typed your name, staple the grading criteria sheet (available from the website soon) to your printout, and submit the hardcopy to your TA at the beginning of your next lab session.
• Late homework assignments are not accepted.