Assignment 03

Due: Friday, Sept. 13, 2019, at noon 100 points

For this assignment, you will submit a single C++ compilable file containing a program written in C++. Remember, to submit a file for this course electronically, from the directory in which the file resides 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! The submit system will deliver every .cpp file in the current directory to me. 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 (fg++) compiler before submitting to make sure that it will work for the submit script. And, to be sure you haven't forgotten, those in the 8 am section are section A, in the 9 am section are section B, in the 10 am section are section C, in the 12 noon section are section D, and those in the 1:00 section are section E.

Background: Your last assignment was to fulfill a programming contract with the distinguished Dr. Nick Riviera. You did well. You did so well that Dr. Nick wants more from you. You see, his receptionist left her employment with him because she valued her professional life and freedom ... from prosecution. So, Dr. Nick's request is that you write a program to act as a receptionist. It is to ask questions of a potential victim patient (someone who walks in the door) and to then give recommendations as to what the person is to do.

I wouldn't let anyone know you worked for Dr. Nick in the future...if you ever want gainful employment, not to be laughed at, friends, and much much more!

Specifications: Your program, if Dr. Nick likes it, will be running on a machine at the entrance to Dr. Nick's office. As patients enter, they will become the user of the program and answer its questions, which in turn will determine whether Dr. Nick welcomes them or throws them out.

Your program will first prompt/read in a name (first name only is fine). The patient (always referred hereafter by name) is asked how much money they have with them. If their answer indicates they have NO money, they are told to "leave the premises immediately....and have a good day. NEXT." If they have money but not as much as $129.95, they are asked "kindly come back when you have at least $129.95." Also if they have at least $129.95, then prompt them for their age. If they are not 21 years of age or older, then they are told "Please leave. You're too young!" If they are between 21 and 65 years of age, inclusive, your program is to ask if they have ever filed a malpractice suit. If the answer is affirmative, then your program should respond with "I'm sorry, we're closed now!" In all other cases, your program should inform the patient that each surgery costs $129.95, and then ask them how many surgeries they want that visit. If

    • the response (number of surgeries) times 129.95 would leave the patient with $129.95 or more, then your program will tell the patient how much the ensuing surgeries will cost in total and how many more surgeries they will be able to purchase that day....and "come on in!"

    • the response (number of surgeries) times 129.95 would leave the patient with less than $129.95, your program will respond with "come on in!"

    • the response (number of surgeries) times 129.95 is more than they have, the program is to tell them so and tell them how many surgeries they can afford and "come on in!"

This will end the interaction with a given potential patient. Your program should then prompt for another patient by saying something like, "Anybody else there??". An affirmative answer ('y/n') will have the user go through the entire "interview" again, and end the program otherwise. Have your program accept 'n' for a negative response, and that should trigger the shut-down of the program, with a polite exiting message. At any time in the interview a potential patient is "asked to leave", this prompt for another patron is invoked.

Remember: When writing your code, be sure to:

    • Use meaningful variable names.

    • Use proper spacing for indentations.

    • Use constant variable declarations where appropriate. Hint: in this assignment, there are several!

    • 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 expected to check the inputs from the user for range acceptance. What that means is that whenever appropriate, an input value should be checked for validity. For example, if the user inputs -8 or 213 for a value of age, then they are to be re-prompted. So what are acceptable ranges? You decide this....and make it a good decision!

Also, since you will be displaying dollar amounts, it's bad form to have $3.50 come out as $3.5. So, put this (magic) code at the top of your main after declarations and it will force exactly two decimal places to be shown always.

cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(2);

Note: Do not use the switch statement in your program. Use if and if-elses.

When you submit the submit script will (attempt to) compile and execute your program in the process. This means that you will be the "user" of the program for that few minutes. Now, in order that the grader isn't driven crazy by a multitude of inputs/outputs, you will ALL input the same values so that he or she has uniform output to grade. They are:

    • enter the doctor's office as a 45 yr old with $800 on you, wanting 4 surgeries, and having never filed a suit.

    • next patient is to be a 18 yr old having $130

    • the next patient is to be a 78 yr old with $356 wanting 5 surgeries.

    • the next patient is 24 having no money.

    • no more patients

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