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

📄 pq7.html

📁 卡耐基课程练习
💻 HTML
📖 第 1 页 / 共 2 页
字号:

  <p>Note: <code>Student[<em>ID</em>,<em>name</em>,<em>grade</em>]</code> is 
    a  representation of a <code>Student</code> object. </p>
</blockquote>
<ol start="4">

  <li> <strong>Implement</strong> the method <code>makeArrayListFromArray</code>:</li>
</ol>
<ul>
  <li><code><em>public static ArrayList&lt;Student&gt;  makeArrayListFromArray(Student[] array)</em></code>. 
    This method takes an array of <code>Student</code> objects and returns an array list <code></code> with the same elements in the same order.</li>

</ul>
<blockquote> 
  <p>For example, consider the following array with three <code>Student</code> objects:</p>
  <pre>  {Student[328,Galileo Galilei,80],
   Student[123,Albert Einstein,100],
   Student[96,Isaac Newton,90]}</pre>
  <p>If <code>makeArrayListFromArray</code> is passed this array, it will return an array list with three <code>Student</code> objects:</p>

  <pre> ArrayList{Student[328,Galileo Galilei,80],
	       Student[123,Albert Einstein,100],
	       Student[96,Isaac Newton,90]}
</pre>
</blockquote>
<ol start="5">
  <li><strong>Implement</strong> the method <code>hasStudent</code>. Use a <code>for-each</code> loop 
    to implement this method.</li>
</ol>

<ul>
  <li><code><em>public static boolean hasStudent(ArrayList&lt;Student&gt; arrayList, int id)</em></code>. 
    This method takes an array list of <code>Student</code> objects and a student ID, 
    returns <code>true</code> if the specified array list contains a student whose 
    ID matches the specified ID. </li>
</ul>
<blockquote> 
  <p>For example, consider the following array list:</p>

  <pre> ArrayList{Student[328,Galileo Galilei,80],
	       Student[123,Albert Einstein,100],
	       Student[96,Isaac Newton,90]}</pre>
  <p>If <code>hasStudent</code> is passed this array list and the id <code>123</code>, 
    it will return <code>true</code>. 
  </p><p>If <code>hasStudent</code> is passed this array list and the id <code>321</code>, 
    it will return <code>false</code>. </p></blockquote>

<ol start="6">
  <li><strong>Implement</strong> the method <code>countGradeGreaterOrEqual</code>. 
    Use a <code>for-each</code> loop 
    to implement this method.</li>
</ol>
<ul>
  <li><code><em>public static int countGradeGreaterOrEqual(ArrayList&lt;Student&gt; arrayList, int 
    grade)</em></code>. This method takes an array list  of <code>Student</code> objects 
    and a grade, and returns the number of students in the specified array list whose 
    grade is greater than or equal to the specified grade.</li>

</ul>
<blockquote> 
  <p>For example, consider the following array list:</p>
  <pre> ArrayList{Student[328,Galileo Galilei,80],
	       Student[123,Albert Einstein,100],
	       Student[96,Isaac Newton,90]}</pre>
  <p>If <code>countGradeGreaterOEqual</code> is passed this array list and the grade 
    <code>100</code>, it will return <code>1</code>. 
  </p><p>If <code>countGradeGreaterOEqual</code> is passed this array list and the grade 
    <code>70</code>, it will return <code>3</code>. </p></blockquote>

<ol start="7">
  <li><strong>Implement</strong> the method <code>getMinGrade</code>. Use an iterator 
    to implement this method.</li>
</ol>
<ul>
  <li><code><em>public static int getMinGrade(ArrayList&lt;Student&gt; arrayList)</em></code>. This 
    method takes an array list of <code>Student</code> objects and returns the smallest 
    grade of the students in the specified array list. To simplify the code, you may 
    assume that the array list is not empty.</li>

</ul>
<blockquote> 
  <p>For example, consider the following array list:</p>
  <pre> ArrayList{Student[328,Galileo Galilei,80],
	       Student[123,Albert Einstein,100],
	       Student[96,Isaac Newton,90]}</pre>
  <p>If <code>getMinGrade</code> is passed this  array list, it will return <code>80</code><code></code>. 
  </p>
</blockquote>

<ol start="8">
  <li><strong>Implement</strong> the method <code>getGradeAverage</code>. Use a <code>for-each</code> loop 
    to implement this method.</li>
</ol>
<ul>
  <li><code><em>public static double getGradeAverage(ArrayList&lt;Student&gt; arrayList)</em></code>. 
    This method takes an array list of <code>Student</code> objects and returns the 
    average grade of the students in the specified array list.<code></code></li>

</ul>
<blockquote> 
  <p>For example, consider the following array list:</p>
  <pre> ArrayList{Student[328,Galileo Galilei,80],
	       Student[123,Albert Einstein,100],
	       Student[96,Isaac Newton,90]}</pre>
  <p>If <code>getGradeAverage</code> is passed this array list, it<code></code> will 
    return <code>90.0</code><code></code>. </p>

</blockquote>
<ol start="9">
  <li><strong>Implement</strong> the method <code>removeGradeLess</code>. Use 
    an iterator to implement this method.</li>
</ol>
<ul>
  <li><code><em>public static void removeGradeLess(ArrayList&lt;Student&gt; arrayList, int grade)</em></code>. 
    This method takes an array list of <code>Student</code> objects and a grade, and 
    removes all students in the specified array list whose grade is less than the 
    specified grade.</li>

</ul>
<blockquote> 
  <p>For example, consider the following array list: </p>
  <pre> ArrayList{Student[328,Galileo Galilei,80],
	       Student[123,Albert Einstein,100],
	       Student[96,Isaac Newton,90]}</pre>
  <p>If <code>removeGradeLess</code> is passed this array list and the grade <code>100</code>, 
    the array list will be modified as follows:</p>
  <pre> ArrayList{Student[123,Albert Einstein,100]}</pre>

</blockquote>
<ol start="10">
  <li><strong>Implement</strong> the method <code>displayAll</code>. Use an iterator 
    to implement this method.</li>
</ol>
<ul>
  <li><code><em>public static String displayAll(ArrayList&lt;Student&gt; arrayList)</em></code>. This 
    method takes an array list of <code>Student</code> objects and returns a string 
    representation of the specified array list. To simplify the code, you may assume 
    that every element in the specified array list contains a valid reference to a 
    <code>Student</code> object.</li>

</ul>
<blockquote>
  <p>Use the method <code>toString</code> in the class <code>Student</code> to 
    obtain the string representation of each object in the array list. A new line 
    character ( \n ) should separate the string representations of the objects.</p>
  <p>For example, consider the following array list:</p>
  <pre> ArrayList{Student[328,Galileo Galilei,80],
	       Student[123,Albert Einstein,100]}</pre>

  <p>If this array list is passed to <code>displayAll</code>, the following string 
    will be returned:</p>
  <pre>  	"Student[328,Galileo Galilei,80]\nStudent[123,Albert Einstein,100]"</pre>
  <p>Note that the string does <em>not</em> end with a new line character ( \n 
    ).</p>
</blockquote>
<h3>Submission</h3>

  
<p>Upon completion, submit <strong>only</strong> the following:</p>
  
<ol>
    
  <li><code>StudentArrayList.java</code></li>
</ol>

<img src="/content/SSD/SSD3/4.2.0.1/normal/pg-class-imp/pg-collctns/assm-qz-pr-java-collctns/pool-pr-java-collctns/qn-pr-java-collctns/handout/resources/inherit.gif" height="1" width="1">
 </td>

<td width="5"><br></td></tr></tbody></table>
<a name="14344"></a><table><tbody><tr>
<td width="5"><br></td>  <td class="td0_x" align="left" valign="top"> <a href="#top_14344">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_14344">File to submit:</label><br> <input class="x" name="file_to_add_14344" 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=14344", 14344, false)' type="submit"></td><td width="5"><br></td></tr></tbody></table>
<hr><input name="pr_state_14344" id="pr_state_14344" value="a:2:{i:0;s:10:&quot;incomplete&quot;;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:45:36 UTC" id="end_date" name="end_date" type="hidden">  <input value="421063" id="course_section_id" name="course_section_id" type="hidden">  <input value="14341" id="assm_id" name="assm_id" type="hidden">  <input value="657624" id="template_id" name="template_id" type="hidden">  <input value="657625" 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 + -