Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

//Class Student class Student { //Member Variable private String firstName; private String surName; private int studentNumber; private double courseWorkMark; private double examMark; public Student() {

//Class Student class Student { //Member Variable private String firstName; private String surName; private int studentNumber; private double courseWorkMark; private double examMark; public Student() { //Empty defalut constructor } //constructor that take first name, surname, student number, courseWorkMark,and examMark as arguments. public Student(String firstName,String surName,int studentNumber, double courseWorkMark, double examMark ) { this.firstName=firstName; this.surName=surName; this.studentNumber=studentNumber; this.courseWorkMark= courseWorkMark; this.examMark= examMark; } //Setter methods //method set first name //It takes a string as parameter //And assign it to first name public void setFirstName(String s) { this.firstName=s; } //method set sur name //It takes a string as parameter //And assign it to surname public void setSurName(String s) { this.surName=s; } //set method student number //It takes a int number as parameter //And assign it to student number public void setStudentNumber(int n) { this.studentNumber=n; } //Getter Methods //method return first name //It does not take any value as parameter public String getFirstName() { return this.firstName; } //method of return Sur name //It does not take any value as parameter public String getSurName() { return this.surName; } //method of return student number //It does not take any value as parameter public int getStudentNumber() { return this.studentNumber; } //method of return the concatenation of the first name and the surname of a Student. //It does not take any value as parameter public String getFullName() { return this.firstName+" "+this.surName; } //method return a string indicating the various data associated with the Student //It does not take any value as parameter public String toString() { return this.firstName+" "+this.surName+" StdNo: "+this.studentNumber; } public void averageMark() { double average =( getcourseWorkMark() + getexamMark()) / 2; System.out.println(average); }

public double getcourseWorkMark() { return this.courseWorkMark; } public double getexamMark() { return this.examMark; } public void setcourseWorkMark(int number) { this.courseWorkMark = number; } public void setexamMark(int number1) { this.examMark = number1; } public void setfirstName(String name ) { this.firstName= name; } public void setsurName(String name2 ) { this.surName= name2; } public void setstudentNumber(int number2) { this.studentNumber = number2; } } //Test class to drive the program public class Test { public static void main(String[] args) { //Create Student class instance Student s1=new Student(); Student s2=new Student("Troy","Astrate.",101095, 20,37); //use of setter method s1.setFirstName("Jan"); s1.setSurName("Krisller"); s1.setStudentNumber(159075); //Check for getter method System.out.println(s1.getFirstName()+" "+s1.getSurName()+" "+s1.getStudentNumber()); //Check for toString method System.out.println(s2.toString()); s2.averageMark(); } }

please could you help me to complete the code above, here is the task:

In your main method create an array that holds three different Student objects

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Database Systems

Authors: Carlo Zaniolo, Stefano Ceri, Christos Faloutsos, Richard T. Snodgrass, V.S. Subrahmanian, Roberto Zicari

1st Edition

155860443X, 978-1558604438

More Books

Students also viewed these Databases questions