Hello there , i've got a problem , i made this program for a Football league stats sheet, but the program needs to grab the highest and the lowest value of each teams in age / weight (poids) / height(taille)

i'm having a really hard time and i'd like someone to point it out to me :) thanks.

#include <iostream.h>

int main()
{
    //Nombre de joueur par équipe
    const int NJOUEUR = 9; 
    //Age des joueurs
    double age;
    //Age total d'equipe
    double  totAgeEquipe;
    //Moyenne age d'equipe
    double moyAgeEquipe;
//AGE
    double nbEquipe;
    double nbEquipeChoisi;
    cout << "Entrez le nombre d'equipe d\x82sir\x82: ";
    cin >> nbEquipeChoisi;
    nbEquipe = 0;
//POIDS
    double poids;
    double totPoidsEquipe;
    double moyPoidsEquipe;
//Taille
    double taille;
    double totTailleEquipe;
    double moyTailleEquipe;

    //AGE
    do
    {   
    totAgeEquipe = 0;
    for (int cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)                                        
    {
        cout << "Entrez l'age du joueur " << cptJoueur + 1 << ": ";                           
        cin >> age;
        totAgeEquipe += age;
    }
    moyAgeEquipe = totAgeEquipe / NJOUEUR;

    cout << "Age des joueurs de l'equipe: ";

    for (cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)
    {
        cout << "joueur " << cptJoueur + 1 << ":" << age << endl;

    }
    nbEquipe++;
    cout << "La moyenne d'age de l'equipe est: " << moyAgeEquipe << endl;
    cout << "Equipe numero: " << nbEquipe << endl;
    }while( nbEquipe != nbEquipeChoisi ); 
//POIDS

    nbEquipe = 0;
        do
    {   
    totPoidsEquipe = 0;
    for (int cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)                                        
    {
        cout << "Entrez le poids du joueur " << cptJoueur + 1 << ": ";                            
        cin >> poids;
        totPoidsEquipe += poids;
    }
    moyPoidsEquipe = totPoidsEquipe / NJOUEUR;

    cout << "Poids des joueurs de l'equipe: ";

    for (cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)
    {
        cout << "joueur " << cptJoueur + 1 << ":" << poids << endl;

    }
    nbEquipe++;
    cout << "La moyenne de poids de l'equipe est: " << moyPoidsEquipe << endl;
    cout << "Equipe numero: " << nbEquipe << endl;
    }while( nbEquipe != nbEquipeChoisi );

//Taille
    nbEquipe = 0;
        do
    {   
    totTailleEquipe = 0;
    for (int cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)                                        
    {
        cout << "Entrez la taille du joueur " << cptJoueur + 1 << ": ";                           
        cin >> taille;
        totTailleEquipe += taille;
    }
    moyTailleEquipe = totTailleEquipe / NJOUEUR;

    cout << "Taille des joueurs de l'equipe: ";

    for (cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)
    {
        cout << "joueur " << cptJoueur + 1 << ":" << taille << endl;

    }
    nbEquipe++;
    cout << "La moyenne de taille de l'equipe est: " << moyTailleEquipe << endl;
    cout << "Equipe numero: " << nbEquipe << endl;
    }while( nbEquipe != nbEquipeChoisi );

Recommended Answers

All 5 Replies

i'll make a quick translation too.. Equipe = team joueurs = players

moyenne = average

i'll recap what I need too , i'm looking for a command ( or function ) to get the min/max value of each the following : age / weight / height

i'm really lost and it's very important , thanks for anyone who spends time replying here :)

i'll make a quick translation too.. Equipe = team joueurs = players

moyenne = average

i'll recap what I need too , i'm looking for a command ( or function ) to get the min/max value of each the following : age / weight / height

i'm really lost and it's very important , thanks for anyone who spends time replying here :)

Please repost using formatting/indenting and code tags:

[code]

// paste code here

[/code]

Please also point out where precisely you are having problems in the code, if it compiles, errors, etc.

re-post

the main part of my problem is that i'm trying to grab the biggest and the lowest value for each teams that are made during the Age/Weight/Height for-loops.

oh , and it does work and compile.

#include <iostream.h>

int main()
{
//Nombre de joueur par équipe
const int NJOUEUR = 9;
//Age des joueurs
double age;
//Age total d'equipe
double totAgeEquipe;
//Moyenne age d'equipe
double moyAgeEquipe;
//AGE
double nbEquipe;
double nbEquipeChoisi;
cout << "Entrez le nombre d'equipe d\x82sir\x82: ";
cin >> nbEquipeChoisi;
nbEquipe = 0;
//POIDS
double poids;
double totPoidsEquipe;
double moyPoidsEquipe;
//Taille
double taille;
double totTailleEquipe;
double moyTailleEquipe;

//AGE
do
{
totAgeEquipe = 0;
for (int cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)
{
cout << "Entrez l'age du joueur " << cptJoueur + 1 << ": ";
cin >> age;
totAgeEquipe += age;
}
moyAgeEquipe = totAgeEquipe / NJOUEUR;

cout << "Age des joueurs de l'equipe: ";

for (cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)
{
cout << "joueur " << cptJoueur + 1 << ":" << age << endl;

}
nbEquipe++;
cout << "La moyenne d'age de l'equipe est: " << moyAgeEquipe << endl;
cout << "Equipe numero: " << nbEquipe << endl;
}while( nbEquipe != nbEquipeChoisi );
//POIDS

nbEquipe = 0;
do
{
totPoidsEquipe = 0;
for (int cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)
{
cout << "Entrez le poids du joueur " << cptJoueur + 1 << ": ";
cin >> poids;
totPoidsEquipe += poids;
}
moyPoidsEquipe = totPoidsEquipe / NJOUEUR;

cout << "Poids des joueurs de l'equipe: ";

for (cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)
{
cout << "joueur " << cptJoueur + 1 << ":" << poids << endl;

}
nbEquipe++;
cout << "La moyenne de poids de l'equipe est: " << moyPoidsEquipe << endl;
cout << "Equipe numero: " << nbEquipe << endl;
}while( nbEquipe != nbEquipeChoisi );

//Taille
nbEquipe = 0;
do
{
totTailleEquipe = 0;
for (int cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)
{
cout << "Entrez la taille du joueur " << cptJoueur + 1 << ": ";
cin >> taille;
totTailleEquipe += taille;
}
moyTailleEquipe = totTailleEquipe / NJOUEUR;

cout << "Taille des joueurs de l'equipe: ";

for (cptJoueur = 0; cptJoueur < NJOUEUR; cptJoueur++)
{
cout << "joueur " << cptJoueur + 1 << ":" << taille << endl;

}
nbEquipe++;
cout << "La moyenne de taille de l'equipe est: " << moyTailleEquipe << endl;
cout << "Equipe numero: " << nbEquipe << endl;
}while( nbEquipe != nbEquipeChoisi );

The code is hard to follow due to lack of indentation. Indentation is critical to seeing the program structure and nested statements.

You say "it does work". What works? Presumably something doesn't work or you wouldn't be posting. Regarding finding the max and min of a group of numbers, generally you create a variable called max and min outside of a loop, initialize the first value to be max and min, then go through the loop. If the new number is less than the current min or greater than the current max, set the min and/or max to be that new number. Here is an example that you can change as needed for your code (it calculates the minimum of five numbers. Calculating the max is a very similar procedure):

int min, userInput;
cout << "Enter a number please : ";
cin >> userInput;
min = userInput; // initialize min to be first value.
for (int i = 1; i < 5; i++)
{
     cout << "Enter a number please : ";
     cin >> userInput;
     if (userInput < min)
          min = userInput;
}

cout << "The minimum is " << min;

YES! that's it , makes tons of sense , thanks ALOT!

i'm sorry for my lack of infos in my coding, I just started to learn C/C++, and my teacher isn't there today , and my paper is due for Monday , thanks a ton for your help sir!!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.