Urgent help me pls !!!!!!!!!!

Hello i have a problem here with my coding in which i have to find the PLAYER with the lowest and highest minutes of play, also the lowest and the highest bonus of the player.

but seems now i can get all the values but only the names of the player. Pls help me with my coding

#include <iostream>
using namespace std;

int main()
{
string name[4];
string position[4];
int age[4];
int weight[4];
int height[4];
string nationality[4];
int min[4];
int goal[4];
int bonus[4];
int total;

cout<<"\t\tFOOTBALL TEAM MANAGEMENT SYSTEM"<<endl<<endl;
cout<<"\t\tPLAYER'S PROFILE"<<endl;
cout<<"************************************************************"<<endl;

for (int i=0; i<4; i++)
{

cout<<"Please enter player's name : ";
cin>>name[i];
cout<<endl;
cout<<"Position of the player : ";
cin>>position[i];
cout<<endl;
cout<<"Age : ";
cin>>age[i];
cout<<endl;
cout<<"Weight : ";
cin>>weight[i];
cout<<endl;
cout<<"Height : ";
cin>>height[i];
cout<<endl;
cout<<"Nationality : ";
cin>>nationality[i];
cout<<endl; cout<<"Minutes played this week : ";
cin>>min[i];
cout<<endl;
cout<<"Goals scored this week : ";
cin>>goal[i];
cout<<endl;

bonus[i] = ((min[i] * 100) + (goal[i] * 500));
cout<<"Bonus for the player is : RM "<<bonus[i]<<endl;

total = total + bonus[i];
cout<<"\tThe total bonus expense for all the players are : RM "<<total<<endl;
cout<<endl<<endl;

int low_Min = min[0];
if (min[i] < low_Min)
{
low_Min = min[i];
}
cout<<"Player name : "<<name[i]<<" has the lowest minutes of play which is : "<<low_Min<<endl;

int high_Min = min[0];
if (min[i] > high_Min)
{
high_Min = min[i];
}
cout<<"Player name : "<<name[i]<<" has the highest minutes of play which is : "<<high_Min<<endl;

int low_Bon = bonus[0];
if (bonus[i] < low_Bon)
{
low_Bon = bonus[i];
}
cout<<"Player name : "<<name[i]<<" has the lowest bonus which is : "<<low_Bon<<endl;


int high_Bon = bonus[0];
if (bonus[i] > high_Bon)
{
high_Bon = bonus[i];
}
cout<<"Player name : "<<name[i]<<" has the highest bonus which is : "<<high_Bon<<endl;


cout<<endl;
cout<<"************************************************************"<<endl;

}
return 0;
}
Last edited on
closed account (48T7M4Gy)
This is an exercise in parallel arrays. The index value of each array ties the arrays together. So if the index of the player with the least score is 2, say, then name[2] is the name of that player, position[2] is their position, weight[2] is their weight etc.

You have to keep track of the index number while at the same time working out the required maximum, minimum or whatever the requirement is for that section.
closed account (48T7M4Gy)
http://www.cplusplus.com/forum/beginner/202845/
@kemort
http://www.cplusplus.com/forum/beginner/202845/

How is that related to the OP's post?
the code is identical...
it's okay i already fixed the problem. tq so much !
Last edited on
good information by kemort, Thank you i had similar problem and got resolved
Topic archived. No new replies allowed.