Java code error
Java code error
A teacher has five students who have taken four tests. The teacher uses the following grading scale to assign a letter grade to a student, based on the average of his or her four test scores:
A=90-100 B=80-89 C=70-79 D= 60-69 F = 0-59
Write a class that uses a String array or an ArrayList object to hold the five students’ names, an array of five characters to hold the five students letter grades, and five arrays of four doubles each to hold each student’s set of test scores. The class should have methods that return a specific student’s name, average test score, and a letter grade based on the average.
Demonstrate the calss in a program that allows the user to enter each students name and his or her four test scores. It should display each students average test score and letter grade.
Do not accept test scores less than zero or greater than 100.
So far this is what I have. I am struggling in adding this to my code: Do not accept test scores less than zero or greater than 100. I am very new to Java so this is causing me a headache.
import java.util.*;
class stats { private String[] student_name; private char[] student_grade; private double[][] student_scores;
public stats() { student_name = new String[5]; student_grade = new char[5]; student_scores = new double[5][4]; Scanner in = new Scanner(System.in); for(int i=0; i=70) student_grade[i] = ‘C’; else if(avg >=60) student_grade[i] = ‘D’; else student_grade[i] = ‘F’; } }
public String getName(int i) { return student_name[i]; } public double getAverage(int i) { double sum = 0; for(int k=0; k
Is this the question you were looking for? If so, place your order here to get started!