2
I have an exercise with the following statement:
Write a class whose objects represent students enrolled in a class. Each object in that class must keep the following student data: registration, name, 2 tasting notes and 1 working note. Write the following methods for this class:
media: calculates the final average of the student (each test weighs 2.5 and the job weighs 2)
final: calculates how much the student needs for the final test (returns zero if it is not for the final)
My code is like this:
public class Aluno {
private String matricula;
private String nome;
private double notaProva;
private double notaTrabalho;
public void media(double nota1, double nota2) {
this.notaProva = nota1;
this.notaTrabalho = nota2;
double mediaPonderada;
mediaPonderada = ((this.notaProva*2.5+this.notaTrabalho*2)/(2+2.5));
System.out.println("Média final: "+ mediaPonderada);
}
public void resultadoFinal() {
}
public void detalhes() {
System.out.println("Nome: "+this.nome);
System.out.println("Matricula: "+ this.matricula);
System.out.println("Nota da prova: "+ this.notaProva);
System.out.println("Nota do trabalho: "+ this.notaTrabalho);
}
public String getMatricula() {
return matricula;
}
public void setMatricula(String matricula) {
this.matricula = matricula;
}
public String getNome() {
return nome;
}
public void setNome(String nome) {
this.nome = nome;
}
}
public class PrincipalMain {
public static void main(String[] args) {
Aluno aluno = new Aluno();
aluno.setNome("Magno");
aluno.setMatricula("20194456458");
aluno.media(9, 5);
aluno.detalhes();
}
}
How do I declare an array in the attribute notaProva
with 2 positions?