Assignment 02

Due: Friday, Sept. 6, 2019, at 12:00 pm (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 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.

Background: Dr. Nick Riviera 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 either on the run or in prisons. But he's landed a job now at the Springfield 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 users weight, age, IQ, and gender of the patient, and also the number tablets per day desired, the strength of the tablets, and Dr. Nick'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.

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. Nick's constant (representing 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) + DNC, where D is the dosage; whole number of pills rounded down in every case. 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 DNC is a constant currently 20 TS is the tablet strength

So, you will first need to greet the user, then prompt the user for input of the values needed to compute the dosage. Once you have calculated the number of pills, output the information in a "user friendly" manner. This is not good output:

50, 60, 100, 2, 250 ...39

Notice that this is a meaningless output, it is incomplete, there is no label on the numbers, etc. Your output should look NICE like:

Dr. Nick, for the inputs:

Age 50

Weight 60 kg

IQ = 100

Gender is 1 ( 1 -> male, 0 -> female )

Frequency is 2

Tablet Strength is 250 mg

The recommended dosage is 39 pills

...Or something like this. You get the picture.

Remember: When writing your code, be sure to:

  • Declare your variables with the APPROPRIATE type.

  • Use meaningful variable names. Don't automatically use the names given in the assignment statement!

  • 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.

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 (1)

  • enter 2 for tablet/day freq

As always, if you have questions, don't hesitate to ask your instructor or the LEAD tutor.