📄 page_369.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>page_369</title> <link rel="stylesheet" href="reset.css" type="text/css" media="all"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> </head> <body> <table summary="top nav" border="0" width="100%"> <tr> <td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_368.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_369</strong></td> <td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_370.html">next page ></a></td> </tr> <tr> <td align="left" colspan="3" style="background: #ffffff; padding: 20px;"> <table border="0" width="100%" cellpadding="0"><tr><td align="center"> <table border="0" cellpadding="2" cellspacing="0" width="100%"><tr><td align="left"></td> <td align="right"></td> </tr></table></td></tr><tr><td align="left"><p></p><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td align="right"><font face="Times New Roman, Times, Serif" size="2" color="#FF0000">Page 369</font></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">//聽Precondition:<br />//聽聽聽聽聽deptID聽contains聽a聽valid聽department聽number<br />//聽&&聽storeNum聽contains聽a聽valid聽store聽number<br />//聽&&聽0.0聽<=聽deptSales聽<=聽25000.0<br />//聽Postcondition:<br />//聽聽聽聽聽A聽line聽of聽the聽bar聽chart聽has聽been聽printed聽with聽one聽*聽for<br />//聽聽聽聽聽each聽$500聽in聽sales,聽with聽fractions聽over聽$250聽rounded聽up<br />//聽聽&&聽No聽stars聽have聽been聽printed聽for聽sales聽</font><font face="Symbol" size="2"></font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">聽<br /><br />{<br />聽聽聽聽cout聽<聽setw(12)聽<聽Dept聽<聽deptID聽<聽endl;<br />聽聽聽聽cout聽<聽setw(3)聽聽<聽storeNum聽<聽聽聽聽聽;<br />聽聽聽聽while聽(deptSales聽>聽250.0)<br />聽聽聽聽{<br />聽聽聽聽聽聽聽聽cout聽<*聽;聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽Print聽*聽for聽each聽$500<br />聽聽聽聽聽聽聽聽deptSales聽=聽deptSales聽-聽500.0;聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽Update聽loop聽control<br />聽聽聽聽}聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽聽//聽聽variable<br />聽聽聽聽cout聽<聽endl;<br />}</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">Testing: We should test this program with data files that contain the same number of data sets for both stores and with data files that contain different numbers of data sets for both stores. The case where one or both of the files are empty also should be tested. The test data should include a set that generates a monthly sales figure of $0.00 and one that generates more than $25,000 in sales. We also should test the program to see what it does with negative days, negative sales, and mismatched department IDs. This series of tests would reveal that, for this program to work correctly for the furniture-store employees who are to use it, we should add several checks for invalid data. In Chapter 8, we revisit this program, adding code for data validation.</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">The </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">main</font><font face="Times New Roman, Times, Serif" size="3"> function of the Graph program not only reflects our top-down design, it calls both </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">GetData</font><font face="Times New Roman, Times, Serif" size="3"> and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">PrintData</font><font face="Times New Roman, Times, Serif" size="3"> twice. The result is a program that is shorter and more readable than one in which the code for each function is physically repeated.</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="17"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">Testing and Debugging</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table border="0" cellspacing="0" cellpadding="0"><tr><td rowspan="5"></td> <td colspan="3" height="12"></td> <td rowspan="5"></td></tr><tr><td colspan="3"></td></tr><tr><td></td> <td><font face="Times New Roman, Times, Serif" size="3">The combination of the formal parameters declared by a function and the actual parameters that are passed to the function by the caller constitutes the interface between the two functions. Errors that occur with the use of functions usually are due to an incorrect interface between the calling code and the called function.</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table></td></tr></table><p><font size="0"></font></p>聽 </td> </tr> <tr> <td align="left" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_368.html">< previous page</a></td> <td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_369</strong></td> <td align="right" width="30%" style="background: #EEF3E2"><a style="color: blue; font-size: 120%; font-weight: bold; text-decoration: none; font-family: verdana;" href="page_370.html">next page ></a></td> </tr> </table> </body> </html>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -