Computer Science, asked by misbabatool95, 4 months ago

Write a C++ program to store the performance of each player of the test match which has been played between Pakistan and South Africa. Input player name, country name, runs scored, counts of wickets taken, good fielding, missed fielding, catches taken, catches dropped for each player of both the teams. You can store this information in array of ‘player’ structure. In the player structure include another data member named performance, which can be calculated using following formula;
Performance = (runs scored / 30) + (wickets taken * 30) + (good fielding * 5) - (missed fielding * 5) + (catches taken * 10) – (catches dropped * 10)
After calculating and updating the performance of every player display the name of the ‘Man of the Match’ (i.e. the player who has highest performance value).

Answers

Answered by dreamrob
0

Program:

#include<iostream>

#include<string.h>

using namespace std;

struct player

{

string name;  

string country;

int runs;  

int wickets_taken;

int good_fielding;  

int missed_fielding;

int catches_taken;

int catches_dropped;

int Performance;

};

int main()

{

int n;

cout<<"Enter total numbers of players playing : ";

cin>>n;

struct player P[n];

for(int i = 0 ; i < n ; i++)

{

 cout<<"Name : ";

 cin>>P[i].name;

 cout<<"Country : ";

 cin>>P[i].country;

 cout<<"Runs : ";

 cin>>P[i].runs;

 cout<<"Wickets taken : ";

 cin>>P[i].wickets_taken;

 cout<<"Good fielding : ";

 cin>>P[i].good_fielding;

 cout<<"Missed fielding : ";

 cin>>P[i].missed_fielding;

 cout<<"Catches taken : ";

 cin>>P[i].catches_taken;

 cout<<"Catches dropped : ";

 cin>>P[i].catches_dropped;

}

int Best = 0, pos=0;

for(int i = 0 ; i < n ; i++)

{

 int A = (P[i].runs / 30);

 int B = (P[i].wickets_taken * 30);

 int C = (P[i].good_fielding * 5);

 int D = (P[i].missed_fielding * 5);

 int F = (P[i].catches_taken * 10);

 int G = (P[i].catches_dropped * 10);

 P[i].Performance = A + B + C - D + F - G;

 if(P[i].Performance > Best)

 {

  Best = P[i].Performance;

  pos = i;

 }

}

cout<<"Man of the match is "<<P[pos].name;

return 0;

}

Similar questions