

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


we now have a student name and an exam name. Both are stored in the field names in the StudentResults class. We can now add an exam score. Add the following new method to your class, just after your examName method: This new method has the name examScore , with an int variable called aScore between its round brackets. It's set to return a String value. The method itself just combines the score with the string " out of 50". So if the value in aScore is 30, the text "30 out of 50" will be stored in the Exam_Score field. In your ExamDetails class, add the following line: String score = aStudent.examScore(30); So we call the new examScore method and hand it a value of 30. The value in the Exam_Score field is returned, and then stored in a string variable that we've called score.
Add a new print line method so that your code looks like ours below: When the programme is run, the Output window now looks like this: So we have the student name, the exam name, and the score out of