Question: DESCRIPITION Write a Java program that will compute and display the final grades for students in a class. A student's final grade is determined from

DESCRIPITION

Write a Java program that will compute and display the final grades for students in a class. A student's final grade is determined from the scores obtained in the class test. Each student in the class may be given a different number of tests as determined by the instructor. The final grade is determined by the average of the scores in all the tests given.

For each student, the program will input student id, name, the number of tests given and scores in each of the tests. The scores in each of the tests will vary from 0 to 100. Each test will carry the same weight. The final grade will be computed by taking the average of the scores in all the tests given (i.e. by adding the scores in all the tests and dividing it with the number of tests given). The final grade will be assigned depending upon the percentage of total points in the tests given as follows:

A 90 to 100%

B 80 to 89%

C 70 to 79%

D 60 to 69%

F 0 to 59%

INSTRUTIONS

Use a String variable for keeping final grade. For comparing two strings use the method: equals( ) or equalsIgnoreCase ( ).

For this assignment create the following classes.

Student class

Create a class Student that provides the following:

Private instance variables for holding student id (int), name (String), test scores (an int array).

A public constructor with parameters for initializing student id (int), name (String) and test scores. The test scores are passed as an array of int.

A public method for returning the final grade as a String ( A, B etc).

Accessor (getter) methods for getting student id and name.

TestStudent class

Write a class TestStudent containing the main method.

Method main

The method main will do the following:

Prompt the user to enter the total number of students (say n).

Create an array of n references (for holding n Student object references). (The Student objects will be created in the next step).

Create n Student objects. Do this by setting up an n count loop. In each pass through the loop, do the following:

a. Ask the user to enter data for one student in a single dialog box.

b. Separate data elements using a StringTokenizer object.

c. Create a Student object initialized with data provided by the user and store its reference in the appropriate element of the array of student references created above.

Display the student results by grade type. First display all students with grade A, then all students with grade B etc. Do this using one of the following two methods. (It is suggested that you use method II as it will help you to learn about String arrays).

Method to use:

Create a String array out of 5 Strings. Use out [0] for accumulating output relating to A students, out[1] for B students etc. Write a static method displayRestult to display output. Call the static method displayResult and pass it the array out.

displayResult

For method II above, write a static method displayResult. This method will receive a String array and display the contents of all elements of the String array one by one. Here is a proposed header for the method:

public static void displayResult (String [ ] s)

{

}

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!