Lab 4

The purpose of this lab is to give you some experience using a function from the math library.

When you finish this lab you should:

  1. Used an include file.
  2. Used a predefined constant (M_PI).
  3. Called a trig function.

Just a little trig to start off with. Trig functions give us the relationship between sides and angles of a right triangle. If we know the length of any side, and either one angle, or the length of any other side, we can find the other angles and the length of all sides. Some of these functions are called the sin, cos, and tan.

One application of these functions is to find the height of a tall object indirectly by measuring the length of the shadow cast and the angle from the end of a shadow to the top of the object.

For example, if a building casts a shadow 26 feet long, and the angle from the end of the shadow to the top of the building is 58 degrees, then the building is 26*tan(58) feet tall. Or about 41 feet tall.

For this lab, write a program that given the length of the shadow, and the angle to the top of a building, calculates and prints out the height of the building.

One additional complication is that C++ expects for angles to be given in radians. To convert from degrees to radians we need to multiply the angle by the number pi and divide by 180. The constant pi is defined as M_PI in <cmath>.

So, at the begiinig of your program, make sure you have

The main body of your program should include these two statements:

When you have finished this program, email the .C file to dbennett@edinboro.edu.