Lab Explorations: Electronic Activity Director

In this activity you will make modifications and enhancements to an already working program.  Record the answers to the questions in your lab notebook.

2. The purpose of this program is to recommend a recreational activity based on the outside air temperature which is entered by the user. Study the source code to understand the logic that is used in determining the results.

3. Based only on your study of the source code, fill in the table below to create a test plan for this program. Invent a series of test data sets that will ensure that every branch in the program is executed at least once. (This is called minimum complete coverage of the branches in the program.)

No.
Description Input Values Expected Output


















   

4. Compile and run the application.

5. Carry out the test plan you wrote above. Is there any discrepancy between the observed output and your expected output? If so, explain.

6. Introduce a logic error in the program by changing

if (temperature > 70)

to

if (temperature < 70)

For what set of input values will the program now produce incorrect results? Explain.

 

Run the modified program with one of the above values to check your prediction. Was your prediction correct? If not, explain any discrepancies.

 

7. The resort owner has installed a hot tub. She wants you to modify the program so that it recommends "hot tubbing" for when the temperature is between 32 and 50 degrees. In your lab notebook, write the code for the needed enhancements to the program.

  

Now make the change to the source code, run the program with an input value of 45. Did the program recommend "hot tubbing?" Run the complete test plan from #1 above, and be sure the rest of the program still works properly. Was your code completely correct?

  

8. Now we want to modify the program so that it will reject inputs that are probably invalid. If the user enters a temperature over 125 degrees over less than -50 degrees, issue a helpful error message and don't recommend an activity. In your lab notebook, write the code for the needed enhancements to the program.

Now make the change to the source code, run the program with input values of 130 and -100. Did the program display the error message? What are the "boundary" cases for error checking? Does the program perform correctly in these cases? Run the complete test plan from #1 above, and be sure the rest of the program still works properly. Was your code completely correct?


9.  In line 10, the function prototype, change "temperature" to "current_temp".  Compile the program and notice if it produces an error message.
Change the remaining lines in the procedure that refer to
"temperature" to "current_temp".   Is it necessary to change "temperature" in the main function?  Explain.

Make sure the program now compiles and runs correctly.

There is nothing to submit for this activity.