Due: Friday, Sept. 12, 2014 at noon 100 points
For this assignment, you will submit a single C++ compilable file containing a program written in C++. Remember, to electronically submit a file to for this course, first change to the directory in which the file resides and then type in, at the UNIX prompt, the command:
cssubmit 1570 section_letter assignment_number
Be sure that only the file you want to submit is in that directory - make a directory for every assignment! Remember that the submit system will deliver every .cpp file in the current directory to me, so you should only have the file for hw 2 in that directory. Name your file a meaningful name and give it a .cpp extension since you will be compiling it. Also, make sure that you compile and run your program using the GNU (g++) compiler before submitting to make sure that it will work for the submit script.
.... or something like this. You get the idea.Remember: When writing your code, be sure to:
Declare your variables with the APPROPRIATE type.
Use meaningful variable names.
Use proper spacing for indentations.
Use constant declarations where appropriate.
Include the comment block at the head of your file.
Comment code that needs it.
Be literate in your welcoming/signing-off messages and prompts and output.
Note: YOU ARE NOT TO USE THE IF STATEMENT IN THE PROGRAM.
When you submit this, and all subsequent programs for this class, cssubmit will compile and run (assuming it compiles) your program during the submission process. Thus, when you submit, you will have to enter inputs as a user of the program. Now, in order to make the output uniform for the grader and to keep her sane, ALL OF YOU will enter the same information. For this assignment, it is:
enter age 45
enter wt 90.2
enter IQ 125
enter as a male
enter 2 for tablet/day freq
As always, if you have questions, don't hesitate to ask your instructor or the LEAD tutor.
1Rounding is accomplished by adding 0.5 to a number and then chopping (truncating, if you like that word better).
Specifications: Your program will prompt the user for age, weight, gender, IQ, and desired number of pills to be taken each day. This information, along with the currently available tablet strength (TS) of 250 mg. and Dr. Eloe's constant (representing the minimum number of tablets he wants to sell to support his lavish live-style) currently 20, will be used in the formula:
D = (Age/IQ) x ((Wt/Freq) + 1) x ((TS/1000) + Gen) + DEC, where D is the dosage; whole number of pills rounded1 from the computation Age and IQ are integers entered by the user Freq is an integer number of pills/day entered by the user. Gen is a user input: 0 - female and 1 - male Wt is a floating point value entered by the user in kg DEC is a constant currently 20 TS is the tablet strength
So, you will begin your program by greeting the user. Then, you need to prompt for and read in the user input for the calculation(s). Once you have determined the number of tablets, output the information appropriately. This means "user friendly" output. This excludes simple output like:
zzzz
Notice that there is no label on the number, etc. Your output should look NICE like:
Dr. Eloe: For the values input: Age = 50 Wt = 60 kg IQ = 100 Gen = male Freq = 2
Tab Strength of 250 mg The recommended dosage is 39 tablets
Background: Dr. Eloe is a physician, in a loose sense of the word, but a physician nonetheless. He has trouble making a living at his profession because he spends so much of his time getting into trouble, either with the law, the administrators of the hospitals where he works, or with his nurses. But he's landed a job now at the Rolla hospital and needs your help. He has developed a wonderful formula for computing prescription dosages (the total number of pills for a given prescription). It's based on the weight, age, IQ, and gender of the patient, and also the number of tablets per day desired, the strength of the tablets, and Dr. Eloe's constant. You are to write a program that he can use to compute the dosage. All it has to do is query the user for input values and output the correct dosage.