COMP 110 First Java Program due date: Wed, Nov. 1 by 4:00 pm Write a Java program that will read in from the keyboard a collection of grades for students and then find the class average on each exam. The averages will be computed and stored along with the data that is input. It will also compute the overall average of all grades across all students. This program will be simple in form. We will use one dimensional arrays to store the data. The program text will be a single Java class (let's say class name GradeAverage) in one file (let's say GradeAverage.java). This class will contain inside this class at least the required main method -- public static void main (String[] args) -- and can have any other methods you want to write to help well organize your code. INPUT FORM For simplicity we will assume that we have 3 exam grades per student, and that there are no missing grades. Let's assume we have some data like this: Smith Bob 45.6 87.9 71.4 Anderson Cathy 78.7 91.3 89.2 Jones William 71.5 53.6 98.2 For now we will keep data input simple... in general, input processing can get rather complex. Let's have the program do this: prompt the user for each item, one per line. So for example, here is how the run would go for the above data: You will be entering student names and grades. Please enter the requested information one item per line. Hit "return" after each line you type. When you have run out of students to enter, give the single character "." as the Last name. Last name? Smith First name? Bob grade? 45.6 grade? 87.9 grade? 71.4 Last name? Anderson First name? Cathy grade? 78.7 grade? 91.3 grade? 89.2 Last name? Jones First name? William grade? 71.5 grade? 53.6 grade? 98.2 Last name? . The final line containing "." is the data flag that says all student data has been entered. The example program "FactQuoter.java" (see the class web page) shows the way to do this input in Java. There will be an unknown (in advance) number of students, but we do know there will not be more than 100 students (meaning we can make out arrays of max size 100). We will need several arrays to store the data -- first names, last names, exam1 grades, exam2 grades, and exam3 grades. We will also need to create an array in which to store the average of the grades for each student. We will use common subscripts to tie it all together; for example, to get the information for one student (let's say student #8) we would examine firstName[8] lastName[8] exam1[8] exam2[8] exam3[8] average[8] OUTPUT FORM When you have received all the input and computed all the averages, print out all the information in tabular form. You will be using "System.out.print" and "System.out.println" to do this, which work very similar to the "Document.write" from JavaScript. However, remember that HTML is a thing of the past now... you will not be writing out any HTML in your output. First print a useful header line that shows what information appears in the columns under it. Then, for each student, print out the student number in parentheses (the array index), the last name, a comma, a space, and the first name. On the same line print two tabs, then the 3 exam grades (a tab after each one); at the end of the line print the average grade. The next student will go on the next line. The last thing I want to see, after all students are shown, is a single line that gives the overall average for the class on all exams. To do this, you add up the averages stored in the average array, and divide by the number of students. It will look something like this: # Student name ex1 ex2 ex3 avg (1) Smith, Bob 45.6 87.9 71.4 68.3 (2) Anderson, Cathy 78.7 91.3 89.2 86.4 (3) Jones, William 71.5 53.6 98.2 74.4333 This class has 3 students. Overall exam average is 76.377 STRATEGY Your program will have several sections to it: (1) a section that reads in data from the user (2) a section that computes the needed averages and stores them (3) a section that generates the output Keep in mind that you will be using concepts that you already know from JavaScript, but expressed in the somewhat new language syntax of Java. So you will be processing these arrays by going through them with for loops. When you are in a for loop (with loop index "k" let's say), you will think of the loop index as defining for you the student number you are working on. Then all the data for that student will be found at firstName[k], lastName[8] exam1[8], exam2[8], exam3[8] average[8] You know how to take an average for any one student... add the 3 grades and divide by 3. For the overall class average, as mentioned above, you can add up the averages stored in the average array and divide by the number of students. FINAL THOUGHTS Remember to use good programming style... use named constants where appropriate, choose meaningful variable names, have a beginning block comment as well as smaller comments throughout, design a clear algorithm, make it all indented and readable.