?? pq1.html
字號(hào):
<span class="dialogueheader">Take Assessment: Practical Quiz 1</span><br><br>
<form name="Assm" id="Assm" method="post" action="https://seqcc.icarnegie.com:443/submitassmcmd.php" enctype="multipart/form-data">
<a name="top_of_page"></a><input name="object_id" id="object_id" value="657482" type="hidden"><table><tbody><tr>
</tr></tbody></table>
<table><tbody><tr>
<td width="5"><br></td> <td class="td0_instructions" align="left" valign="top">
<label class="instructions">Please answer the following question(s).<br>
If the assessment includes multiple-choice questions, click the "Submit Answers" button when you have completed those questions.</label></td>
</tr></tbody></table>
<input name="MAX_FILE_SIZE" id="MAX_FILE_SIZE" value="512000" type="hidden"><table><tbody><tr>
<td width="5"><br></td><script language="JavaScript">document.write('<td class=instructions>' + 'You have 120 minutes to take this assessment.' + '<br>' + 'Please complete this assessment by ' + ComputeLocalDate('2008-11-29 10:33:43 UTC') + '.' + '</td>');</script><td class="instructions">You have 120 minutes to take this assessment.<br>Please complete this assessment by Sat Nov 29 2008 18:33:43 GMT+0800.</td> <td width="5"><br></td></tr></tbody></table>
<a name="top_13639"></a><table><tbody><tr>
<td width="5"><br></td> <td class="td0_highlight-label" align="right" nowrap="nowrap" valign="top" width="12">
<label class="highlight-label">1.</label></td>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"> <a href="#13639">Go to bottom of question.</a> </td>
</tr></tbody></table>
<table><tbody><tr>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"> <!-- new pg 042903 ici -->
<h2 align="center"><cite>iCarnegie</cite> Information</h2>
<h3>Prerequisites, Goals, and Outcomes</h3>
<blockquote> <b><i>Prerequisites:</i></b> Before you begin this exercise, you
need mastery of the following:
<ul>
<li> <em>Java Language</em>
<ul>
<li>Use of Java control structures</li>
</ul>
</li><li><i>Java API</i>
<ul>
<li>Knowledge of package <code>java.io</code>
<ul>
<li>How to get input from the keyboard</li>
<li>How to output results, prompts, and errors</li>
</ul>
</li>
<li>Knowledge of wrapper class <code>Integer</code>: how to read an integer
value as input</li>
</ul>
</li><li> <i>Exception Objects</i>
<ul>
<li>Knowledge of exception handling</li>
<li>Knowledge of <code>NumberFormatException</code></li>
</ul>
</li><li><i>Programming Practice</i>
<ul>
<li>How to produce Java applications</li>
<li>Knowledge of Sun's code conventions</li>
</ul>
<ul>
<li>Knowledge of Javadoc: how to document classes, methods, and variables</li>
</ul>
</li></ul>
<p> <b><i>Goals:</i></b> Reinforce your ability to build console applications
using I/O classes, wrapper classes, and exceptions
</p><p> <b><i>Outcomes:</i></b> You will master the following skills:
</p><ul>
<li> Produce a menu-driven application that reads data from the keyboard and
displays results in the standard output
</li><li>Produce an application that uses:
<ul>
<li>Wrapper classes to read numerical data</li>
<li> Exceptions to handle malformed data</li>
<li>Control structures to control the reading of data</li>
</ul>
</li></ul>
</blockquote>
<h3>Background</h3>
<p>Menus for soliciting input from the user are common in console applications.
This assignment asks you to construct a menu-driven application that reads and
validates user input. Your application will consist of one class called <code>ICarnegieInfoApplication</code>.</p>
<h3>Description</h3>
<p><code>ICarnegieInfoApplication</code> presents the user with a menu of options,
prompts the user for a choice, and processes the user's response:</p>
<ul>
<li>Choice 0 terminates the program.</li>
<li>Choice 1 displays the name of <cite>iCarnegie</cite>.</li>
<li>Choice 2 displays the address of <cite>iCarnegie</cite>.</li>
<li>Choice 3 displays the telephone of <cite>iCarnegie</cite>.</li>
<li>Choice 4 displays the email of <cite>iCarnegie</cite>.</li>
<li>Choice 5 displays the URL of <cite>iCarnegie</cite>.</li>
</ul>
<p> The class <code>ICarnegieInfoApplication</code> uses the class <code>ICarnegieInfo</code>.
<code>ICarnegieInfo</code> stores the contact information for <cite>iCarnegie</cite>.
A complete implementation of <code>ICarnegieInfo</code> is provided in the student
archive <cite><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-dsgn/pg-java-apps/assm-qz-pr-io-tokenzr/pool-pr-io-excptns/qn-pr-icarnegie-info/handout/student-files.zip">student-files.zip</a></cite>. Review
its documentation and become familiar with it. </p>
<ul>
<li><code><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-dsgn/pg-java-apps/assm-qz-pr-io-tokenzr/pool-pr-io-excptns/qn-pr-icarnegie-info/handout/ICarnegieInfo.html" target="internalWindow"><em>ICarnegieInfo</em></a></code>.
Documentation for class <code>ICarnegieInfo</code></li>
</ul>
<p>Note that class <code>ICarnegieInfo</code> does not have a public constructor.
Instead, you will use the method <code>ICarnegieInfo.getInstance</code> to obtain
an instance of the class.</p>
<p>A partial implementation of class <code>ICarnegieInfoApplication</code> is
provided. This class contains the following methods:</p>
<ul>
<li> <code><em>public static void main(String[] args)</em></code>. This method
is complete and requires no modification. <code>main</code> has a loop that
calls the method <code>getChoice</code> to obtain the user's choice. <code>main</code>
then displays the information requested. Choice <code>0</code> causes the
loop to terminate gracefully. </li>
</ul>
<ul>
<li><code><em>private static int getChoice()</em></code>. This method must be
completed. <code>getChoice</code> presents the user with a menu of options
and verifies the user's choice.</li>
</ul>
<h3>Files</h3>
<p>The following files are needed to complete this assignment: </p>
<ul>
<li><cite><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-dsgn/pg-java-apps/assm-qz-pr-io-tokenzr/pool-pr-io-excptns/qn-pr-icarnegie-info/handout/exe-icarnegie-info.jar">exe-icarnegie-info.jar</a></cite>.
Download this file. It is a sample executable.</li>
<li><cite><a href="/content/SSD/SSD3/4.2.0.1/normal/pg-class-dsgn/pg-java-apps/assm-qz-pr-io-tokenzr/pool-pr-io-excptns/qn-pr-icarnegie-info/handout/student-files.zip">student-files.zip</a></cite>. Download
this file. This archive contains the following:
<ul>
<li><cite>ICarnegieInfo.class</cite>. A complete implementation</li>
<li><cite>ICarnegieInfoApplication.java</cite>. Use this template to complete
your implementation.</li>
</ul>
</li>
</ul>
<h3>Tasks</h3>
<p>To complete this assessment, you will implement method <code>getChoice</code>.
The following steps will guide you through this assignment. Document using Javadoc
and follow Sun's code conventions. Work incrementally and test each increment.
Save often. </p>
<ol>
<li><strong>Extract</strong> the student archive by issuing the following command
at the command prompt:
<blockquote><tt>C:\></tt><kbd>unzip student-files.zip</kbd></blockquote>
</li>
</ol>
<ol start="2">
<li><strong>Run</strong> the sample executable by issuing the following command
at the command prompt:
<blockquote><tt>C:\></tt><kbd>java -jar exe-icarnegie-info.jar</kbd></blockquote>
Observe how the program responds to the following types of input:<br>
<ul>
<li>A choice that is not an integer: <kbd>aa</kbd></li>
<li>An integer that is below the valid range: <kbd>-1</kbd></li>
<li> An integer that is above the valid range: <kbd>6</kbd></li>
<li>An integer that is within the valid range: <kbd>1</kbd>, <kbd>2</kbd>,
<kbd>3</kbd>, <kbd>4</kbd>, <kbd>5</kbd> and <kbd>0</kbd></li>
</ul>
</li>
</ol>
<ol start="3">
<li><strong>Next</strong>, complete the implementation of method <code>getChoice</code>:
<p><code><em>protected static int getChoice()</em></code>. This method displays
the following menu of options and prompts the user for a choice. </p>
<blockquote>
<pre>0 – Quit
1 – Display name
2 – Display address
3 – Display telephone
4 – Display email
5 – Display URL
choice></pre>
</blockquote>
<p><code>getChoice</code> then reads and validates the user's input:</p>
<ul>
<li>If the user enters a choice that is not an integer, <a href="http://java.sun.com/j2se/1.5/docs/api/java/lang/NumberFormatException.html" target="externalWindow"><code>java.lang.NumberFormatException</code></a>
is caught and output.</li>
<li> If the user enters an integer outside of the valid range [0,5], an
error message is displayed. </li>
</ul>
<p>If the input is invalid, <code>getChoice</code> re-prompts the user for
a new choice. If the input is valid, <code>getChoice</code> returns the
user's choice. </p>
</li>
</ol>
<h3>Submission</h3>
<p>Upon completion, submit <strong>only</strong> the following:</p>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -