Homework Level: Oprah/Bono/Edge - for Grade D

Make zip file(s) of all of your programs and turn them in on Blackboard under the "Assignment" section for homework - grade D. 

1.  Water Well 

Many private water wells produce only 1 or 2 gallons of water per minute.  One way to avoid running out of water with these low-yield wells is to use a holding tank.  A family of 4 will use about 250 gallons of water per day.  However, there is a "natural" water holding tank in the casing (i.e. the hole) of the well itself.  The deeper the well, the more water that will be stored that can be pumped out for household use.  But how much water will be available?

Write a program that allows the user to input the following in textboxes:

When a button is clicked the program should output the number of gallons of water stored in the well casing to a textbox, label, or message box.

Some conversions for your reference:

For example, a 300 foot well full of water with a radius of 3 inches for the casing holds about 441 gallons of water -- plenty for a family of 4 and no need to install a separate holding tank.

2.  Snow Model

Hanley and Spalinger developed the following snow model to predict how much snow will collect on a mountain slope.  The snow depth predictions were then used to determine how much food is available for moose to eat during winter which was subsequently used to calculate how many moose could survive in a particular area.

 

The base snow depth B in centimeters is calculated by:

The base snow depth says that the higher up you go, the more snow there will be.  We can refine this calculation by including the effects of aspect (north or south facing), slow (how steep the area is), and the canopy coverage (how much the area is covered by trees).

 

The predicted snow depth D in centimeters using these factors is:

The effect of aspect is that south-facing slopes get more sun than north-facing slopes, so there is less snow with a more southerly and exposed aspect.  Aspect is calculated by:

The effect of slope is that steep slopes get less snow than flat slopes.  Slope is calculated by:

The effect of overstory canopy coverage is calculated by:

Write a program that allows the user to input the elevation E (in meters), aspect A (in degrees), slope S (in degrees), and canopy coverage C (0-100).  The program should output the predicted snow depth in centimeters.  Note that C# uses radians for the trigometric functions.  Multiply degrees by Math.PI / 180 to convert degrees to radians.

 

For example, an area at 300m elevation, 180 degree aspect (due south), 25 degree slope, and 90% overstory canopy coverage would have a predicted snow depth of 55.77 cm.

 

Here are the calculations for this example (using degrees, not radians):

  B = 10.3 + (0.27)*E = 10.3 + (0.27)*300 = 91.3

EffectiveAspect = 1 + 0.33 * Cosine(A)*Tangent(S) =

   1 + 0.33*Cosine(180)*Tangent(25) = 1 + 0.33(-1)(0.466) = 0.846

EffectiveSlope = Cosine(S) = Cosine(25) = 0.906

EffectiveCanopyCoverage = (100 - (0.0025*eC/10 ))/100 =

  (100 - (0.0025*e90/10 ))/100 = (100 - 0.0025*8103)/100 =

  (100 - 20.258)/ 100 = 0.797

D = B * EffectiveAspect * EffectiveSlope * EffectiveCanopyCoverage

  = 91.3 * 0.846 * 0.906 * 0.797 = 55.77 

3. Donations

Create a program that accepts and displays how much money has been received in donations.  Here is a sample screenshot of the desired functionality, where the textbox should default to the "suggested donation amount" of $20:

When the user clicks the "Donate" button, the total received so far gets set to its value plus whatever is entered in the textbox.

Here is another example where the user donates $150.

After clicking the "Donate" button, the total received so far is now $170 and the textbox has been reset to the suggested amount of $20. 

In writing this program you should:

  1. Create a class level member variable of type double called amount that is initialized to 0
  2. When the "Donate" button is pressed
    1. set amount equal to itself plus the value entered in the textbox, converted to a double
    2. Display amount in a label to show the total (converted to a string)
    3. Reset the textbox to 20

 

4.  Body Mass Index

The Body Mass Index(BMI) formula was developed by Belgium statistician Adolphe Quelet (1796-1874) and is an internationally used measure of obesity.  The formula to calculate BMI is:

BMI = (weight-in-pounds * 703) / (height-in-inches2)

The interpretation of BMI is as follows:

BMIInterpretation
< 18.5Underweight
>= 18.5 and < 24.9Normal
>= 24.9 and < 29.9Overweight
>= 29.9Obese

Write a program that allows the user to enter their weight in pounds (one textbox) and their height in feet and inches (two textboxes, one to enter feet and the other for inches, e.g. 5 foot 5 inches --> 65 inches total).   Upon clicking a button your program should output to a place of your choice the calculated BMI and whether or not the person is underweight, normal, overweight, or obese.

5.  Piggy Bank Simulator

Write a program to simulate depositing a nickel, dime, or quarter into a piggy bank.  Your program should have the following five buttons: 

Deposit random coin should randomly pick either a nickel, dime, or quarter to deposit into the bank. You can do this by randomly picking a number from 0 to 2, and if it is 0 then make the coin a nickel, if it is 1 then make the coin a dime, and if it is 2 then make the coin a quarter.  

The bank is initially empty.  Every time one of the buttons is clicked a label on the form should be updated that displays the new balance in the piggy bank.  For example, clicking on " Deposit nickel" results in "0.05" displayed in the label.  Clicking on " Deposit quarter" results in "0.30" displayed in the label.  Clicking on "Crack open piggy bank" withdraws all the cash and resets the amount back to 0.  The best way to write this program is to create a class-level variable that stores the amount deposited in the bank.

If you have a variable d with some value such as 0.5 then you can display it as currency as follows:

  double d = 0.5;
  string currency = String.Format("{0:C}", d);

This will set currency to "$0.50"