Sale!

CS 410:Homework 2 solved

$30.00 $25.50

Category:

Description

5/5 - (5 votes)

Instructions: Create a subdirectory named “hw2” in your cs410 directory. Use that subdirectory for
your all file submissions on this assignment. At the end of the homework assignment, these two files
should be found in your hw2 directory:
1. a single C++ compilable file containing a program written in C++ named “hw2.cpp”
2. a “typescript” file demonstating program compilation, execution and testing. Use the commands
below at the UNIX prompt to generate the typescript file:
 script command to start a typescript.
 ls -l to list files in your directory and write date/time
 cat hw2.cpp to print out solution file
 g++ -o hw2 hw2.cpp to compile program
 ./hw2 to execute program with test input (provided on last page)
 exit command to end typescript file
Background: After getting the right thickness of his lenses, Hans Moleman decided to become an
orthopedist. To clarify, that’s a person who treat issues affecting the bones, muscles, tendons, and
ligaments. He seems to have had a history of muscle cramps and pain. Towards this end, he has been
doing some of his own home-grown research, writing up results of exquisite and intricate experiments
on how muscular-aches occur and are mitigated or treated. For the benefit of the general public, he has
published a flow chart on how one might treat or react to bone and muscular issues. His flow chart is
shown on the next page. You’ll notice that, as you follow the flow in this chart (this flow chart), you
eventually end up with either a recommendation or some kind of medical commentary that might help
you out in the near future. Some of it is just simplistic babble, but the user might still find some value
in it.
Specifications: You are to write a program that implements this flowchart. Briefly, your program will
prompt for and input information about the user (the sick person) and use the responses to lead to one
of the “diagnostic messages” Hans has crafted. Of course, you are to do this right. Here are some
requirements:
 You are to use if and if-else statements for decision branching. You are NOT allowed to use the
switch-case statement.
 You are NOT to us the goto, the break, or the continue statements. You are to use logic and
logically structured code to implement.
 Your program should greet the user and prompt for and read in their name (first name only.
Assume the name is a contiguous string of non-whitespace characters). Your code should then
use that name, in at least one prompt, for info after that and in the final
output/diagnosis/recommendation.
 Your program should do what we call “input cleansing” or range checking. That is, when you
prompt for information that can be validated for value, your code should do that. For example,
in many of the prompts you will have, you will ask for a response of yes or no (y/n). If you input
the response as a char, you can then check to see if they indeed entered ‘y’ or ‘n’ and re-prompt
them if not.
 At the end of the execution of a “run” of this stress inquiry, your program should ask the user if
they wish to start again – ostensibly for someone else. In any case, the whole line of questioning
and diagnosis should repeat until no one else has muscular problems.
2
When you submit: When you run your program, use the following responses to questions as indicated
by the flowchart:
 yes, no, no, no, no, no, no, yes
 enter a “yes” response to evaluate another problem
 answer no to all questions
 again, enter a “yes” response to evaluate another problem
 no, yes, no, yes
 enter a “no” response to exit the program
As usual, if you have any questions about this assignment, be sure to ask your TAs or instructor.
Hans Moleman