Student Tracker application

Hey, I need a little help with my application. I want to make a student tracker application in Java. The application should be able to add new students, years, courses, grades and average for grades. I’m using eclipse mars for it.

Here is the student class

public class Student {

public Student(String name, String year, String[] course, int [] grades) {
	super();
	this.name = name;
	this.year = year;
	Course = course;
	Grades = grades;
}
private String name;
private String year;
private String[] Course;
private int [] Grades;


public String getName() {
	return name;
}
public void setName(String name) {
	this.name = name;
}
public String getYear() {
	return year;
}
public void setYear(String year) {
	this.year = year;
}
public String [] getCourse() {
	return Course;
}
public void setCourse(String[] course) {
	Course = course;
}
public int [] getGrades() {
	return Grades;
}
public void setGrades(int [] grades) {
	Grades = grades;
}

public int medieNote (){
int medie = 0;

return medie;
}
}

Here is the Main application class

//import (default package).Student;
import java.util.Scanner;
public class MainApplication {

public static void main(String[] args) {
	String [] w = {"Mate","Fizica"};
	int [] x = {8,9,10};
	Student a = new Student("Ene Cristian","Anul 2", w ,x);
	String [] y = {"Math", "Info"};
	int [] z = {7, 10 ,11};
	Student b = new Student("Popscu Ion","Anul 1", w, x);
	System.out.println(a.getName());
	System.out.println(a.getYear());
	System.out.println(b.getName());
	System.out.println(b.getYear());
}

}

And here is the Course class
public class Course {
private String Courses;
}
Can you please tell me how to make the average for grades, and how to assign new year, courses, and grades for every student, please?
Thank you.

Do you know how to create a method?

Do you know how to compute an average?

There’s not much to explain here, go do it.

that’s the problem. I don’t know how to make the average. And to create a method of what?

You have lots of methods. Copy one and change the name.

An average is computed by summing the terms and dividing by the number of terms

public int getAverageGrade(){
int averageGrade = 0;
for(int grade : Grades){
averageGrade = averageGrade + grade;
}
averageGrade = averageGrade/Grades.length;
return averageGrade;

I have used this method, but it doesn’t work… :frowning:

Looks about right to me. Perhaps you should look closer at in what way it doesn’t work, that probably says a lot about what needs changing.

Exception in thread “main” java.lang.Error: Unresolved compilation problem:
The method getAverageGrade() is undefined for the type Student

at MainApplication.main(MainApplication.java:15)

This is the error that is displayed in console…

Do you disagree with what that says? Maybe it needs moving.

Moving where? In student class?

Where is it supposed to be?
Where is it?

Can you use teamviewer, please?

I’m not pointing out what’s wrong or saying what you should do anyhow. Smells far too much of homework.
I’ll ask obvious questions for you to consider though, I’ll go that far.

What does that error of yours say about the location of your method?
Where do you think it should be?
Where do you think it is?

IT WORKED!! Now i have other problem… It does not displays the courses…

in your code on this line[quote=“terarunner45815, post:1, topic:22520”]
public String getCourse() {
return Course;
}
[/quote]

you are just returning the object(array) at its memory location(as raw data). To print out the array as a String you could use either of the static method java.util.Arrays.toString(array) or java.util.Arrays.asList(array) to achieve that
for example

String [] my_array = {"Mate","Fizica"};
System.out.(Arrays.toString(my_array));//[Mate, Fizica]

You would have to import the utility class java.util.Arrays to use it

NB: The method used above returns a String as specified by the doc in the link provided so you would have to reconsider your return type

There are many other ways to achieve this