Question: I need a check to make sure that the user actually entered a number and NOT a LETTER. I appreciate the help, thank you! package

I need a check to make sure that the user actually entered a number and NOT a LETTER. I appreciate the help, thank you!

package scorer; import java.util.Scanner;

public class Scorer { public static void main(String[] args) { double[][] scores = new double[3][3]; //2 D Array of values getData(scores); //Reading data computeRowAverage(scores); //Computing row average } //Method that reads scores from user public static void getData(double[][] scores) { //Scanner class object Scanner reader = new Scanner(System.in); for(int i=0; i<3; i++) //Iterating over rows { for(int j=0; j<3; j++)//Iterating over columns { //Prompting for value System.out.print(" Input value of element " + i + " " + j + " : "); scores[i][j] = reader.nextDouble();//Storing value in array } } } public static void computeRowAverage(double[][] scores) //Method that computes row average { Scanner in = new Scanner(System.in);//Scanner class object double sum = 0, avg; System.out.print(" Row Average: "); for(int i=0; i<3; i++)//Iterating over rows { sum = 0; for(int j=0; j<3; j++)//Iterating over columns { sum += scores[i][j];//Accumulating sum } avg = sum / 3.0;//Calculating average printRowAverage(i, avg); //Printing row Average } } //Method that prints row average public static void printRowAverage(int rowNumber, double avg) { //Printing formatted row average System.out.printf(" Row: %d \t Average: %.2f ", rowNumber, avg); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!