Write a student class that allow us to store student score


Assignment

TOPIC: Introduction to classes, attributes, methods

Kept track of student numerical scores and equivalent letter grades. The scores were stored in an array, and the grades were stored in a second array. The relationship between the arrays was implicitly based on the index: for example, it was assumed that studentScore[3] is related to studentGrade[3] because they both are for student number 3. In object-oriented programming, we can make this relationship explicit by creating an object and keeping the data together in the object's properties. We can also include pieces of related code in the object's methods.

TASK

Your task is to write code that will be able to create Student objects and store the score and grade data together in the objects as properties. The student object will also be able to print its own data to the screen. You will also write code for a GradingScheme class that will have the functionality to convert any integer score to a letter grade. Then, you will create a user-specified number of students, generate random scores for the students, and convert them to letter grades. Finally, you will calculate the average score, rounded average score, and the average letter grade that corresponds to the rounded average score.

INSTRUCTIONS

1. Create a new class file Student in the project's source package. Write a Student class that will allow us to store student score and student grade in the same object. Also write a printStudent method that will print the student details to the screen.

a. The Student class should have these properties: public int studentId public int score

public char grade

b. The printStudent method will print to the screen the data about the student object. It should print:

Student ID: id; Score: score is grade

where id, score, and grade are the object's data properties. The method should have the following signature, i.e., it returns no value and it requires no parameter:

public void printStudent()

2. Create a new class file GradingScheme in the project's source package. This class will have the functionality to convert an integer score to a letter grade by using its own built-in scheme, so we can use it to convert student scores to grades for all student objects.

a. Use the following to create the class constants:
public static final int [][] GRADING_SCHEME =
{{'F',0}, {'D',60}, {'C',70}, {'B',80}, {'A',90}};

public static final int SCHEME_LETTER=0; public static final int SCHEME_MINIMUM=1;

b. Write a method convertScore that will take an integer as a parameter and return its corresponding letter grade as a char. It should have the following signature:

public char convertScore(int score)

This method could be implemented as a if-else-if tree or more efficiently as a loop. The method starts with the numerical score in the score variable, and should classify it into a letter grade based on the GRADING_SCHEME array data. The method needs to return a char variable.

3. In the driver, write a test case to see if the Student and the GradingScheme code works:

a. Create a GradingScheme object and save its reference in a variable. HINT: This is similar to creating a Scanner object and saving it in a variable keyboard from previous labs.

b. Create one Student object, save its reference in a variable and set its student id and student score properties to some test values.

c. Use the grading scheme object's conversion method to convert the student's object score to a grade and save it in the student object's grade property. HINT: This can be done in one line or in multiple steps:

i. get the student object's score
ii. pass it to the grading scheme object's method for conversion
iii. store the result of the conversion
iv. set the student object's grade to the result

d. Print out the line "Test student:" and use the student object's printStudent method to print the student details. Make sure that the grade matches the score.

e. For example, if the student's id is 786, and the student's score is 78, the output should be:

4. Once you're sure the code works, comment out the printing code.

5. Ask the user for a number of students to create.

6. Declare and dimension an array of appropriate size that will hold student objects as its elements. HINT: the variable type of the array elements is Student.

7. Use a loop to go through the array and do the following for each array element:

a. create a new Student object and save its reference in the array element for future use

b. set the Student object's id so that the students are numbered from 1 to (number of students) HINT: the array elements are numbered from 0 to (number of students-1), so use the loop counter appropriately

c. generate a random score for the student and store it in score. Use Random class' method nextInt(int end) to get numbers from 0 to (end-1). Make student scores be in the range 50-100 inclusive.

d. covert the student score to a letter grade by using the GradingScheme object's conversion method.

e. Finally, use the student's printStudent method to print the student details to the screen

f. Note that for steps b-e you must use the saved reference to the student object from step a.

8. Use a loop to compute an average score of all students.

9. Use a Math's class round method to round the average score to a whole number. HINT: This method takes a double as a parameter and returns a long. Cast the long to an int to save the rounded value in an int variable.

10. Use the grading scheme object's conversion method to get an average letter grade from the rounded average score.

11. Print the average score, rounded average score, and average grade to the screen, see Sample output.

Format your assignment according to the following formatting requirements:

1. The answer should be typed, double spaced, using Times New Roman font (size 12), with one-inch margins on all sides.

2. The response also includes a cover page containing the title of the assignment, the student's name, the course title, and the date. The cover page is not included in the required page length.

3. Also include a reference page. The Citations and references should follow APA format. The reference page is not included in the required page length.

Attachment:- Lab-Assignment.rar

Request for Solution File

Ask an Expert for Answer!!
JAVA Programming: Write a student class that allow us to store student score
Reference No:- TGS02982501

Expected delivery within 24 Hours