Moyenne

Bonjour,

je suis à la recherche d'un bout de code me permettant de calculer la moyenne d'un ensemble de notes. S'il vous plait pourriez vou m'aider?
Cordialement.

1 réponse

  1. salut!!

    voici un bout de code qui calcule la moyenne en java via eclipse.
    dans ce bout de code jè calculé la moyenne de 3 notes

    java coefficient=4

    réseau coefficient=3

    bd coefficient=6

    /*
    * Created on 20 avr. 2012
    *
    * To change the template for this generated file go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    */
    package calcul;

    /**
    * @author user
    * programmeur:varley
    * To change the template for this generated type comment go to
    * Window>Preferences>Java>Code Generation>Code and Comments
    */
    import java.util.*;
    public class moyenne {
    private int java;
    private int reseau;
    private int bd;
    public moyenne(int java ,int reseau,int bd) {
    this.java=java;
    this.reseau=reseau;
    this.bd=bd;
    }
    public float calculermoyenne(){
    float somme,moyenne;
    somme=this.java*4+this.reseau*3+this.bd*6;
    moyenne=somme/13;
    return moyenne;
    }

    public static void main(String[] args) {
    int x,y,z;
    float rest;
    Scanner s=new Scanner(System.in);
    System.out.println("entrer la note de java" );
    x=s.nextInt();
    System.out.println("entrer la note de reseau" );
    y=s.nextInt();
    System.out.println("entrer la note de bd" );
    z=s.nextInt();

    moyenne add=new moyenne(x,y,z);

    rest=add.calculermoyenne();

    System.out.println("la moyenne de l'etudiant est "+rest );
    }
    }