Question
What to submit: 2 files 1. The Student class (Student.java) 2. A screenshot of your output window Note, you don't need to submit the main
What to submit: 2 files
1. The Student class (Student.java)
2. A screenshot of your output window Note, you don't need to submit the main class this time because I will provide the implementation of it, let's use the same code to test your Student class Total point: 100 Goal: Practice basic operations for single dimensional array Let's improve the Student class with arrays. Instruction:
1. Open IDE and create a new project (yourFirstnameLastnameLab3).
2. Create a Student class in this project
3. Add a private variable for first name
4. Add a private variable for Last name
5. Add a constructor that takes 2 string parameters to set the 2 class variables for names
6. Add getter and setters methods for 2 name variables
7. Add a toString method to build a String description for the student object using names
8. Dedare 2 more private instance variables
a. One is an int array for lab scores: lakscores
b. Another one is an int array for exam scores: exove Scenes Do not instantiate them, do not give any initial values (Reason: we want Student class to be a place holder for data, but let client program provide the specific value. We can reuse Student class to calculate and report scores for different classes, but each class may have different number of labs or exams) C. 9. Add getter and setter methods for the 2 new int array variables (we want to write safe code to protect our instance variables in Student class) setlabsceses setlabsarres, getexpasseres. SetExam Scores Let's improve out reportAverage cateAndGradefortabs method (we will move some code that is common for lab scores and exarni scores to private method, so we can reuse them) 10. Create a private method, calculate total that will take an int array as arguments, return an int as total for all numbers in the array. private int calculate total (int[] scores) int total // your calculation here return total 11. Create another private method called determineletterGrade, that will take a double as average score and return a char as letter grade. I private char detecmiochet Sada double score) Let's can use the same criteria as labs: Above (include) 90. A Above (include) 80:8 Above (include) 70.C Below (not include) 70: F 12. Now let's add one public method to reportGrade Forlabs public void terocardedabso{-} This method will: + Call calculate Total method to get the total score for labs. + Calculate average lab score by using the total score and the length of labscores array, make sure the average contains fractional part. For example, the average of 95 and 100 should be 975 + Call determineletter Gtade method to get the letter grade for labs. + Print out the average score and the letter grade for lab. 13. Add another public method to reportGuadeForExams public void terorterade Foxxams (- This method will do the same as reportGrade Fotlabs, but use the int array for exams lesem scores) for the calculation, 14. Test the Student class in main method (vourfirstnameLastnamelab3.java) Create 3 Student objects, assign lab and exam scores to them, make sure you give them different numbers to produce different letter grade Call ceportGrade Eetlabs and reportGradeferExams for each of them to generate a nice report card. Your output may look like this: Name: Lan Hu Average lab score is 90, you got an A Average exam score is 85, you got a B 90, 100, 70 total will be 190 average will be 190/2 90, 100, 70 total will be 260 average will be 260/3
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