Greetings everyone
I'm starting to program with java, so I'm stuck in this exercise, could someone point me to the solution?
Thanks
define a class Student that has:
● 3 attributes:
- A String studentName
- A String studentSurname
- A double marksAverage
● A constructor method that takes 3 params (name, surname, average) and assign the values to the right attributes
● A static method getAverageMark() that:
- Accepts as parameter a listOfMarks, where the List has an upper bound wildcard related to Number for relaxing the restriction so that:
- The listOfMarks can be a List of integers or double
● Calculates the average using:
- listOfMarks.get(0).doubleValue() to get the first value from the list
- listOfMarks.get(1).doubleValue() to get the second value from the list
- The arithmetic summation operator and the arithmetic division operator
- Returns the average value as double
● An override of the toString() method that returns a String with all the Student attributes.
Considering that:
- There are two types of marks for the students:
- A List of 2 Double elements for individual marks
- A List of 2 Integer elements for project marks
- Lisa Stuart has a List called individualMarksListLisa of individual marks
- Jeremy Green has a List called projectMarksListJeremy of project marks
● Define a testing class with a method main() where you:
create the individualMarksListLisa list
add two random double values to the list using the .add() built-in method of the List
- Create the projectMarksListJeremy list
- Add two random int values to the list using the .add() built-in method of the List
- Calculate (using the static method Student.getAverageMark()) the marks average
double values for lisaAvg and jeremyAvg
- Create a listOfStudents
- Add the two new Student objects (Lisa and Jeremy) to the list, using the add() method and the Student's constructor
● Print in console the details of the two Students inside the listOfStudents using:
- The override method
- The get() built-in method from List
The code I started is this
What I have tried:
public class Student {
public String studentName;
public String studentSurname;
public double marksAverage;
public Student(String studentName, String studentSurname, double marksAverage){
this.studentName = "Luca";
this.studentSurname = "Reina";
this.marksAverage = 7.2;
}
public static void getAverageMark(){
}
}