1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| public class GestionNotes{
public static void main (String [] args ) {
System.out.println (" debut - execution ");
System.out.println ();
System.out.println (" Tableau à 2 dimensions ");
System.out.println ("------------------------ ");
System.out.println ("nombre d eleves ? :");
int nbreleve = Lire.entierInt ();
System.out.println ("nombre de notes par élève ? :");
int nbrenotes = Lire.entierInt();
//creation , declaration du tableau
double [][] tabnotes = new double [nbreleve][nbrenotes];
//remplissage tableau
for (int i = 0 ; i <= tabnotes.length -1 ;i++){
System.out.println (" note pour l eleves " + (i+1)+ " ?" );
for (int j=0 ;j <= tabnotes[1].length -1 ; j++){
System.out.println (" note " + (j +1) + " ? " );
tabnotes[i][j] = Lire.reelDouble();
}
}
//affichage matrice
System.out.println ("affichage des notes");
for (int i = 0 ; i <=tabnotes.length - 1 ; i ++){
System.out.println ();
for (int j = 0 ;j <= tabnotes[1].length -1 ; j ++ ){
System.out.printf ("%4.2f" , tabnotes [i][j]);
System.out.print ( " ");
}
}
}
} |
Partager