Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Elev JP
Elev JP
import javax.swing.*;
import java.util.*;
import javax.swing.JOptionPane;
int n=Integer.parseInt(JOptionPane.showInputDialog("n="));
int i;
Elev elevi[]=new Elev[n];
for(i=0;i<n;i++)
{
System.out.println("Elevul "+(i+1));
String nume=JOptionPane.showInputDialog("nume=");
int nota=Integer.parseInt(JOptionPane.showInputDialog("nota="));
elevi[i]=new Elev(nume,nota);
}
System.out.println("Media elevilor este= "+Catalog.calcMedia(elevi));
}
}
import java.io.*;
public class Catalog {
public static double calcMedia(Elev[] elevi)
{
int suma=0;
for(int i=0;i<elevi.length;i++)
suma+=elevi[i].getNota();
double medie=(double)suma/elevi.length;
return medie;
}
}