Question
(1a) 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
(1a)
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)
{
}
------------------------------------
(1b)
DESCRIPTION
Write a Java program that will compute and display the final grades for a list of students. A students final grade is determined from the scores obtained in the class tests. 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.
This program is an enhancement of a previous exercise that did the same. However, this exercise will additionally provide for assigning a CR or NCR (Credit or No Credit) grade.
For each student, the program will input student id, name, the number of tests given and scores in each of the tests.
Additionally, it will input the grade type: Letter or Credit. The grade type of Letter will indicate that student will receive a grade of A, B, C, D, or F. The grade type of Credit will indicate that the student will receive a grade of CR or NCR.
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%
Additionally, for a grade type of Credit, the grade will be determined as follows:
If the student qualifies for a C or better grade, the student will be assigned a CR (Credit) grade. Otherwise, the student will be assigned an NCR (No Credit) grade.
INSTRUCTIONS
Use a String variable for keeping final grade.
Use a String variable for keeping grade type.
Comparing Strings
For comparing two Strings for equality, use one of the following two String methods:
equals
equalsIgnoreCase
IMPLEMENTATION
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.
Accessor (getter) methods for getting student id, name, test scores .
Instead of rewriting this class, you may copy the contents of the same class from a previous exercise.
StudentExt class.
Create a class StudentExt that extends the class Student above. This class will extend the class Student in order to provide additional functionality for assigning a CR or NCR grade.
The class will provide the following:
A private String instance variable gradeType for indicating the grade type (Letter or Credit). The variable gradeType will record Letter for a letter grade type and Credit for Credit/No Credit grade type.
A public constructor for initializing student id (int), name (String), test scores (an int array) and grade type (String). This constructor will call the parent class constructor for initializing student id, name and test scores. It will initialize the grade type itself directly.
A public method for returning the final grade. This method will over ride the parent class method used for computing the grade. This method will have the same name and the same parameter profile as the parent class method. This new method will call the parent class method (of the same name) to compute the student letter grade. After return from the parent class method, in the case of grade type Credit, it will change the letter grade returned by the parent class method to either CR or NCR.
TestStudentExt class
Write a class TestStudentExt containing the main method. 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 StudentExt object references). (The StudentExt objects will be created in the next step).
Create n StudentExt 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.
b. Create a StudentExt object and initialize it with data provided by the user. Store the object reference in the array of StudentExt references created above.
Display the student results by grade type. First display students receiving grade A, followed by those receiving B, followed by those receiving C, followed by those receiving D, followed by those receiving F, followed by those receiving Cr, followed by those receiving NCR.
You may do this in a number of ways including the following:
Method:
Create a String array out of 7 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 the method 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)
{
}
Thanks a lot.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started