Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program called GradesAverage, which prompts user for the number of stude

ID: 3554859 • Letter: W

Question

Write a program called GradesAverage, which prompts user for the number of students, reads it from the keyboard, and saves it in an int variable called numStudents. It then prompts user for the grades of each of the students and saves them in an int array called grades.

Your program must:
1. Make sure you store the grades entered in an array.
2. Compute the average in a separate method from the main().
3. Check the numStudents is a number, otherwise continue to prompt until they do.
4. Check the grade is between 0 and 100, otherwise continue to prompt until they do.
5. Have the user's entry from the console stay on the same line. (see example below)

Enter the number of students: hello
You did not enter an integer.
Enter the number of students: hi
You did not enter an integer.
Enter the number of students: 6
Enter the grade for student 1: 100
Enter the grade for student 2: 97
Enter the grade for student 3: 108
Invalid grade, try again

Explanation / Answer

import java.io.BufferedReader;
import java.io.InputStreamReader;


public class GradesAverage {


   private static int checkNum(String num) {
       int tmpNum;
       try {
           tmpNum = Integer.valueOf(num);
       } catch(IllegalArgumentException e) {
           System.out.println("You did not enter an integer.");
           return -1;
       }
       return tmpNum;
   }

   private static boolean validNum(int num) {
       if(num>=0 && num<=100) {
           return true;
       }
       System.out.println("You did not enter an integer, try again

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote