Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


Share this Page URL
Help

Chapter 5. Conditions, Logical Expressio... > Case Study Follow-Up - Pg. 238

238 CHAPTER 5 Conditions, Logical Expressions, and Selection Control Structures the maximum score (three strikes) is 30. If the first throw knocks down fewer than 10 pins, but the second throw knocks down the remainder of the 10 pins (a spare), then the score is those 10 points plus the number of pins knocked down on the third throw. If the first two throws fail to knock down all of the pins (a blow), then the score is just the total number of pins knocked down in the first two throws. Your program should output the computed score, and also should check for erroneous input. For example, a throw may be in the range of 0 through 10 points, and the total of the first two throws must be less than or equal to 10, except when the first throw is a strike. Be sure to use proper formatting and appropriate comments in your code. The output should be labeled clearly and formatted neatly, and the error messages should be informative. 7. Use functional decomposition to write a C++ program that computes a dance competi- tion score. There are four judges who mark the dancers in the range of 0 to 10, and the overall score is the average of the three highest scores (the lowest score is excluded). Your program should output an error message, instead of the average, if any of the scores are not in the correct range. Be sure to use proper formatting and appropriate comments in your code. The output should be labeled clearly and formatted neatly, and the error message should indicate clearly which score was invalid. 8. Use functional decomposition to write a C++ program that determines the median of three input numbers. The median is the middle number when the three numbers are arranged in order by size. However, the user can input the values in any order, so your program must determine which value is between the other two. For example, if the user enters then the program would output Once you have the three-number case working, extend the program to handle five numbers. Be sure to use proper formatting and appropriate comments in your code. The output should be labeled clearly and formatted neatly. Case Study Follow-Up 1. How might you go about choosing values for 2. 3. 4. 5. and so that the BMI values of 20, 25, and 30 are tested? Change the program so that the BMI is rounded. Choose appropriate cases to test the end conditions. Implement your test plan. Change the program so that it takes metric values for the weight and height. Go on the Internet to find the correct formula. Change the original program so that the height is entered in feet and inches. Prompt for and enter them separately. A negative input value for or was considered an error condition in the BMI program. Are there other values for or that should be considered error conditions? Explain.