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];
}
}
Posta o erro ai pra gente avaliar?
O erro foi colocado no código
Na sua classe Estudante, onde está o método exibir(); ?
Até mais!
[quote=AlexandreGama]Na sua classe Estudante, onde está o método exibir(); ?
Até mais![/quote]
O método exibir da classe estudante é:
void exibir() {
System.out.println("Matricula: " + matricula);
System.out.println("Nome:" + nome);
System.out.println(" sexo:" + sexo);
System.out.println(" notas:" + notas);
}
Me expressei mal viniciussspds, sorry!
Quis dizer “Olha onde está seu método”.
Creio que esteja no local errado:
[code] 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);
e.exibir(); [/code]
Até mais!
Não sei se é realmente isso, mas só dei uma arrumada:
[code]
public class TesteEstudante {
private static Estudante e;
double nota1 = e.lerNota(1);
double nota2 = e.lerNota(2);
double nota3 = e.lerNota(3);
double nota4 = e.lerNota(4);
public static void main(String[] args) {
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);
exibir1();
}
public static 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);
e.exibir();
}
} [/code]
Seria mais ou menos isso?
Abraços!
[quote=AlexandreGama]Não sei se é realmente isso, mas só dei uma arrumada:
[code]
public class TesteEstudante {
private static Estudante e;
double nota1 = e.lerNota(1);
double nota2 = e.lerNota(2);
double nota3 = e.lerNota(3);
double nota4 = e.lerNota(4);
public static void main(String[] args) {
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);
exibir1();
}
public static 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);
e.exibir();
}
} [/code]
Seria mais ou menos isso?
Abraços![/quote]
Muito Obrigado, é isso mesmo.
Que bom!
Se não entendeu alguma modificação, como o static que inseri, é só dar um toque.
Até mais!