Olá Pessoal,
Esse código consigo compilar mas não consigo rodar por que será ? da o seguinte erro.
Exception in Thread “main” java.lang.NoClassDefFoundError: Aluno
import javax.swing.*;
import java.io.*;
class Cadastro
{
String nome;
int sala;
double prova1;
double prova2;
double prova3;
double media;
Cadastro(String a, int b,double c, double d, double e, double f)
{
nome = a;
sala = b;
prova1 = c;
prova1 = d;
prova1 = e;
media = f;
}
}
class Aluno
{
static Cadastro [] leitura(Cadastro v[]) throws IOException
{
int i;
FileReader Arq1 = new FileReader("sandro.txt");
BufferedReader BArq1 = new BufferedReader(Arq1);
for( i = 0 ; i < 3 ; i++)
{
v[i].nome = BArq1.readLine();
v[i].sala = Integer.parseInt(BArq1.readLine());
v[i].prova1 = Double.parseDouble(BArq1.readLine());
v[i].prova2 = Double.parseDouble(BArq1.readLine());
v[i].prova3 = Double.parseDouble(BArq1.readLine());
}
JOptionPane.showMessageDialog(null,"Dados lidos do arquivo");
BArq1.close();
Arq1.close();
return v;
}
static void apresentar(Cadastro v[])
{
int i=0;
double media=0;
String msg="";
media = (v[i].prova1 + 2) * ( v[i].prova2 + 3) * (v[i].prova3)/6;
for( i = 0 ; i < 3 ; i++)
{
msg = msg + "nome " + v[i].nome + " sala " + v[i].sala + " prova1 " + v[i].prova1 + " prova2 " + v[i].prova2 + " prova3 " + v[i].prova3 + media + "\n";
}
JOptionPane.showMessageDialog(null,msg);
}
static void Inserir( ) throws IOException
{
int i;
int sala;
String nome;
double prova1, prova2, prova3;
FileWriter ArqSaida = new FileWriter ("Saida.txt", true);
BufferedWriter BArqSaida = new BufferedWriter (ArqSaida);
nome = JOptionPane.showInputDialog("Digite o nome do aluno");
sala =Integer.parseInt(JOptionPane.showInputDialog("Digite a sala"));
prova1 = Double.parseDouble(JOptionPane.showInputDialog("Digite a 1a nota"));
prova2 = Double.parseDouble(JOptionPane.showInputDialog("Digite a 2a nota"));
prova3 = Double.parseDouble(JOptionPane.showInputDialog("Digite a 3a nota"));
BArqSaida.write(nome + "\n");
BArqSaida.write(sala + "\n");
BArqSaida.write(prova1 + "\n");
BArqSaida.write(prova2 + "\n");
BArqSaida.write(prova3 + "\n");
ArqSaida.close();
JOptionPane.showInputDialog (null,"Dados inseridos");
}
static void Salvar(Cadastro v[]) throws IOException
{
int i;
FileWriter ArqSaida = new FileWriter("Saida.txt");
BufferedWriter BArqSaida = new BufferedWriter(ArqSaida);
for (i = 0 ; i < 3 ; i++)
{
BArqSaida.write(v[i].nome + "\n");
BArqSaida.write(v[i].sala + "\n");
BArqSaida.write(v[i].prova1 + "\n");
BArqSaida.write(v[i].prova2 + "\n");
BArqSaida.write(v[i].prova3 + "\n");
}
BArqSaida.close();
ArqSaida.close();
JOptionPane.showMessageDialog(null, "Dados gravados no arquivo");
}
public static void main(String arg []) throws IOException
{
Cadastro vet[] = new Cadastro [3];
int op;
for (int i=0 ; i< 3 ; i++)
{
vet[i] = new Cadastro ("",0,0.0,0.0,0.0,0.0);
}
do
{
op = Integer.parseInt(JOptionPane.showInputDialog("Digite uma opção"));
switch (op)
{
case 1 :
vet = leitura(vet);
break;
case 2 :
apresentar(vet);
break;
case 3 :
Inserir( );
break;
case 4 :
Salvar(vet);
break;
case 5 :
System.exit(0);
default : JOptionPane.showMessageDialog (null,"Opção inválida");
}
} while (op != 5);
}// void main
} //classe
se alguem puder me ajudar. obrigado.