?? pq6.html
字號:
ID, and returns the <code>Employee</code> object with the specified ID. This
method returns <code>null</code> if there are no employees in the specified
array with the specified ID.</li>
</ul>
<blockquote>
<p>For example, consider the following array:</p>
<blockquote>
<pre>{Employee[102,Mary Jones,60000.0],
Employee[101,Joe Smith,20000.0],
Employee[103,Richard Wong,40000.0]}</pre>
</blockquote>
<p>If <code>getEmployee</code> is passed this array and the integer <code>103</code>,
it will return the <code>Employee</code> object for Richard Wong. If <code>getEmployee</code>
is passed this array and the integer <code>222</code>, it will return <code>null</code>.
</p></blockquote>
<ol start="6">
<li><strong>Implement</strong> the method <code>countHigherSalaries</code>. Use a <code>for-each</code> loop to implement this method.</li>
</ol>
<ul>
<li><code><em>public static int countHigherSalaries(Employee[] array, double
amount)</em></code>. This method takes two arguments, an <code>Employee</code>
array and a dollar amount, and returns the number of employees in the specified
array whose salary is higher than the specified dollar amount.</li>
</ul>
<blockquote>
<p>For example, consider the following array:</p>
<blockquote>
<pre>{Employee[102,Mary Jones,60000.0],
Employee[101,Joe Smith,20000.0],
Employee[103,Richard Wong,40000.0]}</pre>
</blockquote>
<p>If <code>countHigherSalaries</code> is passed this array and the double <code>50000.0</code>,
it will return <code>1</code>. If <code>countHigherSalaries</code> is passed
this array and the double <code>20000.0</code>, it will return <code>2</code>.
</p>
</blockquote>
<ol start="7">
<li><strong>Implement</strong> the method <code>sumSalaries</code>. Use a <code>for-each</code> loop to implement this method.</li>
</ol>
<ul>
<li><code><em>public static double sumSalaries(Employee[] array)</em></code>.
This method takes an <code>Employee</code> array and returns the sum of the
salaries of the employees in the specified array.</li>
</ul>
<blockquote>
<p>For example, consider the following array:</p>
<blockquote>
<pre>{Employee[102,Mary Jones,60000.0],
Employee[101,Joe Smith,20000.0],
Employee[103,Richard Wong,40000.0]}</pre>
</blockquote>
<p>If <code>sumSalaries</code> is passed this array, it will return <code>120000.0</code>.
</p>
</blockquote>
<ol start="8">
<li><strong>Implement</strong> the method <code>getHighestSalary</code>. Use indexes to implement this method.</li>
</ol>
<ul>
<li><code><em>public static double getHighestSalary(Employee[] array)</em></code>.
This method takes an <code>Employee</code> array and returns the highest salary
in the specified array. To simplify your code, you can assume that the specified
array contains one or more elements. </li>
</ul>
<blockquote>
<p>For example, consider the following array:</p>
</blockquote>
<ol start="8">
<blockquote>
<pre>{Employee[102,Mary Jones,60000.0],
Employee[101,Joe Smith,20000.0],
Employee[103,Richard Wong,40000.0]}</pre>
</blockquote>
</ol>
<blockquote>
<p>If this array is passed to <code>getHighestSalary</code>, it will return
<code>60000.0</code>. </p>
</blockquote>
<ol start="9">
<li><strong>Implement</strong> the method <code>increaseAll</code>. Use a <code>for-each</code> loop to implement this method.</li>
</ol>
<ul>
<li><code><em>public static void increaseAll(Employee[] array, double amount)</em></code>.
This method takes two arguments, an <code>Employee</code> array and a dollar
amount, and increases the salary of every employee in the specified array
by the specified amount. </li>
</ul>
<blockquote>
<p>For example, consider the following array:</p>
</blockquote>
<ol start="8">
<blockquote>
<pre>{Employee[102,Mary Jones,60000.0],
Employee[101,Joe Smith,20000.0],
Employee[103,Richard Wong,40000.0]}</pre>
</blockquote>
</ol>
<blockquote>
<p>If <code>increaseAll</code> is passed this array and the integer <code>1000</code>,
the array will be modified as follows:</p>
</blockquote>
<ol start="8">
<blockquote>
<pre>{Employee[102,Mary Jones,61000.0],
Employee[101,Joe Smith,21000.0],
Employee[103,Richard Wong,41000.0]}</pre>
</blockquote>
</ol>
<ol start="10">
<li><strong>Implement</strong> the method <code>displayAll</code>. Use indexes to implement this method.</li>
</ol>
<ul>
<li><code><em>public static String displayAll(Employee[] array)</em></code>.
This method takes an <code>Employee</code> array and returns a string representation
of the specified array. To simplify your code, you can assume that every element
in the specified array contains a valid reference to an <code>Employee</code>
object. </li>
</ul>
<blockquote>
<p>Use the method <code>toString</code> in the class <code>Employee</code> to
obtain the string representation of each object in the array. A new line character
( <code>\n</code> ) should separate the string representations of each <code>Employee</code>
object.</p>
<p>For example, consider the following array:</p>
</blockquote>
<ol start="10">
<blockquote>
<pre>{Employee[102,Mary Jones,61000.0],
Employee[103,Richard Wong,41000.0]}</pre>
</blockquote>
</ol>
<blockquote>
<p> If this array is passed to <code>displayAll</code>, the following string
will be returned: </p>
</blockquote>
<blockquote>
<pre> "Employee[102,Mary Jones,61000.0]\nEmployee[103,Richard Wong,41000.0]"</pre>
</blockquote>
<blockquote>
<p>Note that the string does <em>not</em> end with a new line character ( <code>\n</code>
). </p>
</blockquote>
<h3>Submission</h3>
<p>Upon completion, submit <strong>only</strong> the following.</p>
<ol>
<li><code>EmployeeArray.java</code></li>
</ol>
<p><img src="/content/SSD/SSD3/4.2.0.1/normal/pg-class-imp/pg-collctns/assm-qz-pr-arrays/pool-pr-arrays/qn-pr-arrays-empl/handout/resources/inherit.gif" height="1" width="1"></p> </td>
<td width="5"><br></td></tr></tbody></table>
<a name="14336"></a><table><tbody><tr>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"> <a href="#top_14336">Go to top of question.</a> </td>
<td width="5"><br></td></tr></tbody></table>
<hr><table><tbody><tr>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"><label class="lbl0-x" for="file_to_add_14336">File to submit:</label><br> <input class="x" name="file_to_add_14336" value="" size="20" maxlength="500" type="file"> </td>
<td width="5"><br></td><td valign="bottom"> <input class="x" value="Upload File" name="add_file" id="add_file" style="width: 12em;" onclick='return SetUploadTime("https://seqcc.icarnegie.com:443/takeassmcmd.php?question_id=14336", 14336, false)' type="submit"></td><td width="5"><br></td></tr></tbody></table>
<hr><input name="pr_state_14336" id="pr_state_14336" value="a:2:{i:0;s:10:"incomplete";i:1;a:0:{}}" type="hidden"><table><tbody><tr>
</tr></tbody></table>
<input name="max_mins_per_try" id="max_mins_per_try" value="120" type="hidden"> <input value="2008-11-29 10:43:39 UTC" id="end_date" name="end_date" type="hidden"> <input value="421063" id="course_section_id" name="course_section_id" type="hidden"> <input value="14333" id="assm_id" name="assm_id" type="hidden"> <input value="657602" id="template_id" name="template_id" type="hidden"> <input value="657603" id="record_id" name="record_id" type="hidden"> <input value="" id="client_time" name="client_time" type="hidden"><table><tbody><tr>
<td width="5"><br></td> <td class="td0_x" align="left" valign="top"> <a href="#top_of_page">Go to top of assessment.</a> </td>
</tr></tbody></table>
<table><tbody><tr>
<td width="5"><br></td> <td class="td0_copyright" align="left" valign="top"> ? Copyright 2006 iCarnegie, Inc. All rights reserved. </td>
</tr></tbody></table>
</form>
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -