Objectives: To learn to code, compile, and run a program containing a REPETITION construct.
Assignment:
Plan and code a program utilizing one or more repetition constructs to solve the following problem: Assume that a patient takes a capsule containing 130 mg of a certain drug along with an 8-oz cup of water. Assume further that the drug is absorbed immediately into the body. After this drug is absorbed into the body, 7.4% is eliminated from the body each hour. Write a program to calculate and display the following:
(a) The number of [integer] hours required until only approximately one-half the original amount (65 mg ± 2%) remains in the body.
(b) The amount of the drug remaining in the body for each of the 24 hours after the person takes the drug.
Input:
(a) The patient's first name, capturing one name only even if multiple names are entered.
(b) The patient's last name, capturing up to three names (e.g., von Trapp or de la Rosa).
Output:
(a) The patient's name, displayed as: Last, First, in proper "sentence case". That is, for the patient's first name, capitalize [only] the first letter with lowercase for the remainder of the letters. For the patient's last name, capitalize only the first letter of the last name entered. See the example last name above (notice the capital R in de la Rosa); all other letters are to be in lowercase.
(b) A listing of the amount of the drug remaining after each hour until 24 hours is reached.
(c) The number of hours required until only 65 ± 2% mg of the drug remains in the body.
Note:
Adequately check entered data for validity. Ensure that "sentence case" is correct regardless of the letters entered. Use adequate test data to process all valid data and representative data to show how your program handles invalid data. Label all output clearly. Be sure your output file contains user prompts and what was entered by the user in addition to the results of your program processing. (We may need to discuss this next item – perhaps next week?) BE SURE TO INCLUDE ADEQUATE ERROR HANDLING IN YOUR PROGRAM AND ERROR DATA WHEN YOU RUN THE PROGRAM TO DEMONSTRATE ERROR HANDLING.