|
|
|
|
|
|
|
9. Write a program segment that prints out the sequence of all the hour and minute combinations in a day, starting with 1:00 A.M. and ending with 12:59 A.M. |
|
|
|
|
|
|
|
|
10. Rewrite the code segment for Exercise 9 so that it prints the times in 10minute intervals, arranged as a table with six columns and 24 rows. |
|
|
|
|
|
|
|
|
11. Change program Incomes (page 290) so that it |
|
|
|
 |
|
|
|
|
a. prints an error message when a negative income value is input and then goes on processing any remaining data. The erroneous data should not be included in any of the calculations. Thoroughly test the modified program with your own data sets. |
|
|
|
 |
|
|
|
|
b. does not crash when there are no males in the input file or no females (or the file is empty). However, it should print an appropriate error message. Test the revised program with your own data sets. |
|
|
|
 |
|
|
|
|
c. rejects data sets that are coded with a letter other than F or M and prints an error message before continuing to process the remaining data. |
|
|
|
|
|
|
|
|
12. Develop a thorough set of test data for program Incomes as modified in Exercise 11. |
|
|
|
|
|
|
|
|
1. Write a top-down design and a C++ program that inputs an integer and a character. The output should be a diamond composed of the character and extending the width specified by the integer. For example, if the integer is 11 and the character is an asterisk (*), the diamond would look like this: |
|
|
|
 |
|
|
|
|
*
***
*****
*******
*********
***********
*********
*******
*****
***
* |
|
|
|
 |
|
|
|
|
If the input integer is an even number, it should be increased to the next odd number. Use meaningful variable names, proper indentation, appropriate comments, and good prompting messages. |
|
|
|
|
|
|
|
|
2. Write a top-down design and a C++ program that inputs an integer larger than 1 and calculates the sum of the squares from 1 to that integer. For example, if the integer equals 4, the sum of the squares is 30 (1 + 4 + 9 + 16). The output should be the value of the integer and the sum, properly labeled. A negative input value signals the end of the data. |
|
|
|
|
|
|
|
|
3. You are putting together some music tapes for a party. You've arranged a list of songs in the order in which you want to play them. However, you would like to minimize the empty tape left at the end of each side of a cassette (the cassette plays for 45 minutes on a side). So you want to figure out the total time for a group of songs and see how well they fit. Write a top-down design and a C++ program to help you do this. The program should input a reference number and a |
|
|
|
|
|