Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing Java Arrays to get min & max
    primarykey
    data
    text
    <p>thank you for your help.</p> <p>Here is the assignment:</p> <blockquote> <p>Computer Technology Instructor has a small class of 10 students. The instructor evaluates the performance of students in the class by administering 2 midterm tests and a Final Exam. Write a program that prompts the instructor to enter the 10 grades of midterm 1 and store these numbers in an array. Next prompt for the 10 grades of midterm 2 and store these numbers in a different array. Next prompt for the 10 grades of the Final Exam and store these in a different array. Next add midterm1 to midterm2 to Final and store the totals in a different array. <strong>Next, scan the array that has the totals and identify the minimum grade and maximum grade. Inform the instructor of the minimum grade and maximum grade.</strong></p> </blockquote> <p>The two bold phrases are where I am having problems. Everything works except for the minimum grade and maximum grade. Here is what it tells me, after I've only entered numbers between 65 and 100:</p> <blockquote> <p>The highest test score is: 276 The lowest test score is: 249</p> </blockquote> <p>Here is my code:</p> <pre><code>import java.util.Scanner; public class Arrays { public static void main(String[] args) { // Create a scanner Scanner input = new Scanner(System.in); // Prompt for the 1st mid term int [] midTerm1 = new int[10]; int [] midTerm2 = new int[10]; int [] finalExam = new int[10]; int [] grades = new int[10]; for (int i = 0; i &lt; midTerm1.length; i++){ System.out.println("Enter the 10 Mid Term 1 grades: "); midTerm1[i] = input.nextInt(); } // Prompt for the 2nd mid term for (int i = 0; i &lt; midTerm2.length; i++){ System.out.println("Enter the 10 Mid Term 2 grades: "); midTerm2[i] = input.nextInt(); } // Prompt for Final grades for (int i = 0; i &lt; finalExam.length; i++){ System.out.println("Please enter a Final Exam grade: "); finalExam[i] = input.nextInt(); } for (int i = 0; i &lt; grades.length; i++){ grades[i] = (midTerm1[i] + midTerm2[i] + finalExam[i]); } int minGrade = grades[0]; int maxGrade = grades[0]; for (int i = 0; i &lt; grades.length; i++) { if (minGrade &gt; grades[i]) minGrade = grades[i]; if (maxGrade &lt; grades[i]) maxGrade = grades[i]; } System.out.print("The highest test score is: " + maxGrade); System.out.print("The lowest test score is: " + minGrade); } } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload