After caffeine is absorbed into the body, 13% is eliminated from the body each hour. Assume a person drinks an 8-oz cup of brewed coffee containing 130 mg of caffeine, and the caffeine is absorbed immediately into the body. Using Visual Basic, write a program to calculate the following values. See the figure below.
- The number of hours required until 65 mg (one-half the original amount) remain in the body.
- The amount of caffeine in the body 24 hours after the person drinks the coffee.
- Suppose the person drinks a cup of coffee at 7 a.m. and then drinks a cup of coffee at the end of each hour until 7 a.m. the next day. How much caffeine will be in the body at the end of the 24 hours?
Suggested Control Names and Attributes:
Name Property | Text Property | Control Type | Notes |
frmCaffeine | Caffeine | Form | Holds Controls |
btnCalculate | Calculate Values | Button | Triggers event to calculate and display values |
txt65mg | TextBox | Displays when 65 mg will remain* | |
txt24Hours | TextBox | Displays mg after 24 hours * | |
txtHourlyCup | TextBox | Displays mg after 1 cup per hour * |
* Set Read Only property of the TextBox to True.