Question: Inheritance Problem: Davy Jones is a programming instructor at Gulf National University. He wants a program that will allow him to enter a student's name
Inheritance Problem: Davy Jones is a programming instructor at Gulf National University. He wants a program that will allow him to enter a student's name and grades and then print a report for that student. There are two types of grades, a programming grade and an exam. The programs are worth percent of the grade and the exam is worth percent. The exam is a composed of truefalse and multiplechoice questions. Each question is worth the same amount of points. For the exam, Dr Jones wants the program to allow his teaching assistants to enter the number of questions and then the number missed. The programs are graded on three different aspects, the documentation eg UML, flowchart at percent, how well the code keeps to the coding standards, another percent, and how well the code works, at percent. Here, Dr Jones wants the user to be able to enter those three scores, based on points for each. For this course, there are a number of programming grades and one exam. Once the user has entered the grades the program will print a report showing the grades for the programming assignments, the grade for the final exam and the final grade in the class. Programming notes Your book has the code for a GradedActivity class. It also has code for a subclass called FinalExam. This class extends the GradedActivity class. The code for these two classes and starting code for the main class have been included along with this assignment. There is one change made to the GradedActivity class that is not in the book. The setScore has been changed to 'protected'. Do not change that back to public; we'll talk more about what this means in our Advanced Java course. Note that the FinalExam knows how to calculate the score based on the questions and number missed. You do not need to modify that code. You must create a new class called ProgramAssignment. This class must extend the GradedActivity class. Look at the FinalExam class for an example. There are other examples in your book. This class will have three fields, documentationScore, standardsScore and correctnessScore. The values for these fields will be assigned in the constructor. Each of the fields should have a getter. However, the class should have NO SETTERS. In the constructor, the grade should be calculated and then the setScore method in the GradedActivity that is the parent class should be called. The percentages listed above should be public static final variables in your ProgramAssignment class. Do not hardcode these. Use them in your constructor to calculate the grade. For example, if the scores are documentation coding standards and correctness then the grade will be calculated as for a total of You would call setScore with Note that I have hardcoded the values here; as I mentioned, you should be using named constants. Here is the UML for this class, ignoring the getters. I included a calculateScore method just to keep the constructor cleaner. No other methods are needed. If you add additional methods your grade may be negatively affected. ProgramAssignment DOCUMENTATIONPERCENT:int STANDARDSPERCENT:int CORRECTNESSPERCENT:int documentationScore:int standardsScore:int corectnessScore:int ProgramAssignmentintint,intcalculateScore:double When the program is run, it should be clear to the user how to use the program. It should first prompt for the students name. Then it should ask whether there is a program score to enter. As long as the user answers 'yes', the program should prompt for the scores for documentation, standards and correctness one at a time Each time through the loop, a new ProgramAssignment should be created and added to an array list of ProgramAssignment classes that is ArrayList When the user indicates that there are no more programs to be entered, the program will prompt for the number of questions and number of questions missed on the final exam. These will be used to create a FinalExam class. Since there is only one of these, there is no need to have an array; a simple variable will do The printout of the results should look like this: Program grades: Program Score Grade B A B Average: B Final Exam: Missed Score Grade A Course Grade: B Think about how to get these values. Remember that a class that extends another class inherits the public methods that are in that class. You need to take advantage of that fact. Use concepts you have been learning in this class to make the code easier to understand and maintain. Use methods where appropriate. Having a method that prompts for the grades and creates and returns a ProgramAssignment object would make sense. Don't calculate the final grade in main, do this in a method that takes the ProgramAssignment array list and the final exam object and returns the grade.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
