⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 page_232.html

📁 Programming and Problem Solving with C++
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">	<html>		<head>			<title>page_232</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_231.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_232</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_233.html">next page&nbsp;&gt;</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 232</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="Times New Roman, Times, Serif" size="3">signed is an abbreviated way of asserting that </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">someVariable</font><font face="Times New Roman, Times, Serif" size="3"> has already been assigned a meaningful value.</font></td><td></td></tr><tr><td colspan="3"></td></tr><tr><td colspan="3" height="1"></td></tr></table><table cellpadding="0" cellspacing="0" border="0" width="100%"><tr><td height="12"></td></tr><tr><td><table cellspacing="0" width="528" cellpadding="7"><tr><td valign="top"><font face="Times New Roman, Times, Serif" size="2"><i>Module</i></font></td><td valign="top"><font face="Times New Roman, Times, Serif" size="2"><i>Precondition</i></font></td><td valign="top"><font face="Times New Roman, Times, Serif" size="2"><i>Postcondition</i></font></td></tr><tr><td valign="top"><font face="Times New Roman, Times, Serif" size="2">Main</font></td><td valign="top"><font face="Times New Roman, Times, Serif" size="2"></font></td><td valign="top"><font face="Times New Roman, Times, Serif" size="2">A letter and four integer values have been input AND Either the number of board feet or the number of plywood sheets has been calculated and displayed</font></td></tr><tr><td valign="top"><font face="Times New Roman, Times, Serif" size="2">Get Data</font></td><td valign="top"><font face="Times New Roman, Times, Serif" size="2"></font></td><td valign="top"><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">code</font><font face="Times New Roman, Times, Serif" size="2">, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">size1</font><font face="Times New Roman, Times, Serif" size="2">, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">size2</font><font face="Times New Roman, Times, Serif" size="2">, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">size3</font><font face="Times New Roman, Times, Serif" size="2">, and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">numOrdered</font><font face="Times New Roman, Times, Serif" size="2"> have been input</font></td></tr><tr><td valign="top"><font face="Times New Roman, Times, Serif" size="2">Calculate Lumber Amount</font></td><td valign="top"><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">code</font><font face="Times New Roman, Times, Serif" size="2"> equals L AND </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">size1</font><font face="Times New Roman, Times, Serif" size="2">, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">size2</font><font face="Times New Roman, Times, Serif" size="2">, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">size3</font><font face="Times New Roman, Times, Serif" size="2">, and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">numOrdered</font><font face="Times New Roman, Times, Serif" size="2"> are assigned</font></td><td valign="top"><font face="Times New Roman, Times, Serif" size="2">The number of board feet has been computed and printed</font></td></tr><tr><td valign="top"><font face="Times New Roman, Times, Serif" size="2">Calculate Plywood Amount</font></td><td valign="top"><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">code</font><font face="Times New Roman, Times, Serif" size="2"> equals P AND </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">size1</font><font face="Times New Roman, Times, Serif" size="2">, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">size2</font><font face="Times New Roman, Times, Serif" size="2">, </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">size3</font><font face="Times New Roman, Times, Serif" size="2">, and </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="2">numOrdered</font><font face="Times New Roman, Times, Serif" size="2"> are assigned</font></td><td valign="top"><font face="Times New Roman, Times, Serif" size="2">The number of plywood sheets has been computed and printed</font></td></tr></table></td></tr></table><br /><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">Now that we've established the preconditions and postconditions, we walk through the main module. At this point, we are concerned only with the steps in the main module, so for now we assume that each lower-level module executes correctly. At each step, we must determine the current conditions. If the step is a reference to another module, we have to verify that the precondition of that module is met by the current conditions.</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">First we assume that Get Data correctly inputs a letter and four integer values. Then the If statement checks to see if the letter is an L. If it is, the computer takes the Calculate Lumber Amount branch. Assuming Calculate Lumber Amount correctly calculates and prints the quantity ordered (remember, we're assuming that the lower-level modules are correct for now), that branch of the If statement is correct.</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">If the letter in </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">code</font><font face="Times New Roman, Times, Serif" size="3"> is not an L, the computer takes the Calculate Plywood Amount branch. Here we have a problem. The precondition of Calculate Plywood Amount asserts that the value of </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">code</font><font face="Times New Roman, Times, Serif" size="3"> is P, but the only condition that has been established is that </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">code</font><font face="Times New Roman, Times, Serif" size="3"> does not contain an L. As we have written it, the algorithm calculates the quantity of full sheets ordered if anything other than an L is entered for </font><font face="Courier New, Courier, Mono New, Courier, Mono" size="3">code</font><font face="Times New Roman, Times, Serif" size="3">. So the algorithm works as long as the data is entered correctly, but it does not catch incorrect data. This is poor design, and we return to the problem later. But first let's finish up the walk-through.</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_231.html">&lt;&nbsp;previous page</a></td>				<td align="center" width="40%" style="background: #EEF3E2"><strong style="color: #2F4F4F; font-size: 120%;">page_232</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_233.html">next page&nbsp;&gt;</a></td>			</tr>		</table>		</body>	</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -