Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design a class of Student that has the following attributes: Data members: first

ID: 3694264 • Letter: D

Question

Design a class of Student that has the following attributes:

Data members: first name, last name, ID, Mathematics score and Biology score.

Function members:

(1) A default constructor and a constructor that accepts actual arguments.

(2) The get methods that return names and ID.

(3) A compAveScore() function that computes and returns the average score.

      average score = (Mathematics score + Biology score)/2.0

In the main function, test the Student class as follows:

Declare an array of three elements.

Create three Student objects: a(“Amy”, ”Miller”, 1001, 60, 66), b(“John”, “Smith”, 1002, 70,77) and c(“Eric”, “Taylor”, 1003, 80, 88), and then assign three objects to the array.

Loop through all objects to print out their names, IDs and average scores in a nice format:

Amy   Miller 1001 63.0

John Smith 1002 73.5

Eric Taylor 1003 84.0

Explanation / Answer

output:

Amy Miller 1001 63.0
John Smith 1002 73.5
Eric Taylor 1003 84.0
BUILD SUCCESSFUL (total time: 0 seconds)

Program:

class Student
{
String firstName,lastName;
int ID,mathsScore,BiologyScore;
Student(String f,String l,int i,int m,int b)
{
firstName=f;
lastName=l;
ID=i;
mathsScore=m;
BiologyScore=b;
}
String getFirstName()
{
return firstName;
}
String getLastName()
{
return lastName;
}
int getID()
{
return ID;
}
double compAveScore()
{
double average = (mathsScore + BiologyScore)/2.0;
return average;
}
}
public class test {
public static void main(String agrs[])
{
Student s[]={new Student("Amy","Miller", 1001, 60, 66), new Student("John","Smith", 1002, 70, 77), new Student("Eric","Taylor", 1003, 80, 88)};
  
for(int i=0;i<3;i++)
{
System.out.println(s[i].getFirstName()+" "+s[i].getLastName()+" "+s[i].getID()+" "+s[i].compAveScore());
}
}
  
}

output:

Amy Miller 1001 63.0
John Smith 1002 73.5
Eric Taylor 1003 84.0
BUILD SUCCESSFUL (total time: 0 seconds)

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote