(Resolvido)Problema com método exibir

8 respostas
V

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];
        
    }
}

8 Respostas

F

Posta o erro ai pra gente avaliar?

V

O erro foi colocado no código

AlexandreGama

Na sua classe Estudante, onde está o método exibir(); ?

Até mais!

V

AlexandreGama:
Na sua classe Estudante, onde está o método exibir(); ?

Até mais!

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);
	}
AlexandreGama

Me expressei mal viniciussspds, sorry!
Quis dizer "Olha onde está seu método".

Creio que esteja no local errado:

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();

Até mais!

AlexandreGama

Não sei se é realmente isso, mas só dei uma arrumada:

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();  
	}  
	  
}

Seria mais ou menos isso?

Abraços!

V
AlexandreGama:
Não sei se é realmente isso, mas só dei uma arrumada:
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();  
	}  
	  
}

Seria mais ou menos isso?

Abraços!

Muito Obrigado, é isso mesmo.

AlexandreGama

Que bom!
Se não entendeu alguma modificação, como o static que inseri, é só dar um toque.

Até mais!

Criado 21 de outubro de 2010
Ultima resposta 21 de out. de 2010
Respostas 8
Participantes 3