Estou com erro no método e.exibir() e restante abaixo, o código é o seguinte:
Classe TesteEstudante
public class TesteEstudante {
public static void main(String[] args) {
Estudante e = new Estudante();
e.matricula = 2004001;
e.nome = "Maria Silva";
e.sexo = 'f';
e.atribuirNota(1, 7.0);
e.atribuirNota(2, 8.2);
e.atribuirNota(3, 6.0);
e.atribuirNota(4, 5.5);
}
void exibir1(){
System.out.println(" matricula = "+ 2004001);
String Maria = null;
System.out.println(" nome = "+ Maria);
System.out.println(" sexo = "+ 'f');
System.out.println(" nota1 = " + 7);
System.out.println(" nota2 = " + 8);
System.out.println(" nota3 = " + 6);
System.out.println(" nota4 = " + 5);
}
//erro: Multiple markers at this line
// - Return type for the method is missing
// - Syntax error, insert ";" to complete MethodDeclaration
// - Syntax error, insert ")" to complete MethodDeclaration
// - Syntax error on token "exibir", Identifier expected after
// this token
e.exibir(){
//e cannot be resolved
double nota1 = e.lerNota(1);
double nota2 = e.lerNota(2);
double nota3 = e.lerNota(3);
double nota4 = e.lerNota(4);
}
}
Classe Estudante
public class Estudante {
public class exibir {
}
int matricula;
String nome;
char sexo;
double[] notas = new double[4];
void exibir() {
System.out.println("Matricula: " + matricula);
System.out.println("Nome:" + nome);
System.out.println(" sexo:" + sexo);
System.out.println(" notas:" + notas);
}
void atribuirNota(int numProva, double nota){
notas[numProva-1]= nota;
}
double lerNota(int numProva){
return notas[numProva -1];
}
}