Question

In: Computer Science

Create a structure in C called BarcelonaPlayer with the following members. struct BarcelonaPlayer { char name[20];...

Create a structure in C called BarcelonaPlayer with the following members.
struct BarcelonaPlayer
{
char name[20];
int age;
char country[20];
char Position[20];
double Salary;
double Rating;
};
First, create an array of BarcelonaPlayer structures. Now, write a function that takes an array of BarcelonaPlayer structures as input and find out the highest paid player among all the players.
void highestPaidPlayer(struct BarcelonaPlayer *pl, int size);
Create another function that finds all the players from Argentina.
void findPlayers(struct BarcelonaPlayer *pl, int size);

Solutions

Expert Solution

Thanks for the question.
Below is the code you will be needing Let me know if you have any doubts or if you need anything to change.
Thank You!


===========================================================================

#include<stdio.h>
#include<string.h>
struct BarcelonaPlayer
{
char name[20];
int age;
char country[20];
char Position[20];
double Salary;
double Rating;
};

void highestPaidPlayer(struct BarcelonaPlayer *pl, int size){
   int i;
   int highestIndex=0;
   for( i=0;i<size;i++){
       if(((pl+i)->Salary)>((pl+highestIndex)->Salary)){
           highestIndex =i;
          
       }
   }
  
   printf("Player with highest salary is %s",(pl+highestIndex)->name);
}

void findPlayers(struct BarcelonaPlayer *pl, int size){
  
   int i;
   int highestIndex=0;
   for( i=0;i<size;i++){
       if(strcmp((pl+i)->country,"Argentina")==0){
          
           printf("\nPlayer from Argentina: %s",(pl+i)->name);
       }
   }
  
}
int main(){
  
  
   struct BarcelonaPlayer players[]{
       {"Messi",34,"Argentina"," ",4560000,2},{"Ronaldo",34,"Brazil"," ",4560010,4},{"Luiz",34,"Argentina"," ",456010,14},
       {"Griezman",19,"France"," ",14560010,1},{"Ansu",27,"England"," ",5555,14}
   };

   highestPaidPlayer(players,5);
   findPlayers(players,5);
  
}

====================================================================

let me know if you have any doubts or if you need anything to change.

If you are satisfied with the solution, please rate the answer.

Thanks!


===========================================================================


Related Solutions

Implement stack in C Struct: struct patients{ int id; int severity; char *firstName; char *lastName; char...
Implement stack in C Struct: struct patients{ int id; int severity; char *firstName; char *lastName; char *state; int time_spent; }; Given Array: struct patients* patientsArray[4] = {&p1, &p2, &p3, &p4}; Create two functions one for pushing this array to the stack and one for popping the variables such as p1 p2 p3 p4 by its ID
Program #include<iostream> using namespace std; struct bookRecord //structure definition {             //structure members definition char title[30];...
Program #include<iostream> using namespace std; struct bookRecord //structure definition {             //structure members definition char title[30];             char main_author[30];             int year_publish;             float price; }; int main() {             struct bookRecord book1; // declare structure variable;             //Get data from user             cout<<"Enter book title: ";             cin>>book1.title;             cout<<"Enter main author name: ";             cin>>book1.main_author;                     cout<<"Enter year publish: ";             cin>>book1.year_publish;             cout<<"Enter book price RM: ";             cin>>book1.price;             //Print the information the screen output            ...
Create a struct for the following groups of data: (a) Product Data with the following members...
Create a struct for the following groups of data: (a) Product Data with the following members • ID • Name • Price • Quantity (b) Customer Data with the following members • ID • Name • Address • E-mail (c) Sales Data with the following members • Customer ID • Product IDs • Sale amount • Choose the types that you think will work best for the above descriptions. • Names should have a maximum size of 50. • Physical...
This project requires the student to create a record (in C++ called a struct). The record...
This project requires the student to create a record (in C++ called a struct). The record should contain several fields of different data types and should allow the user to search the records to find the student with the highest grade. In this project the student should gain an understanding of the nature of records with multiple data types, how to save the records, search the records and retrieve them.  The special problems of maintaining records of multiple data types on...
write a Program in C++ Using a structure (struct) for a timeType, create a program to...
write a Program in C++ Using a structure (struct) for a timeType, create a program to read in 2 times into structures, and call the method addTime, in the format: t3 = addTime(t1, t2); Make sure to use add the code to reset and carry, when adding 2 times. Also, display the resultant time using a function: display(t3);
Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of...
Name your c++ file Word_LastNameFirstName.cpp. Create a struct that has a word and the length of the word. Next, use the struct to store the word read from a text file call “word.txt” and the length of the word. Print out the word x number of times based on the length of the word as shown below. Also, print a statement with the length and determine if the string length has an odd number or even number of characters. You...
Write a C program that creates a structure and displays its content. • Create a struct...
Write a C program that creates a structure and displays its content. • Create a struct that will be used to hold a student's name, age, and year in school (Freshman, Sophomore, Junior, or Senior) • Within function main, dynamically allocate space to hold the structure and assign a pointer to point to the memory space allocated • Read in (from the keyboard) the student's name, age, and year in school • Create a separate function with the prototype: void...
use c++ language. Create a structure called time. Its three members, all type int, should be...
use c++ language. Create a structure called time. Its three members, all type int, should be called hours, minutes, and seconds. Write a program that prompts the user to enter a time value in hours, minutes, and seconds. This should be in 12:59:59 format. This entire input should be assigned first to a string variable. Then the string should be tokenized thereby assigning the 1st token to hours, 2nd token to minutes, and 3rd token to seconds member variables of...
The following is a structure template: struct box { char maker[40]; float height; float width; float...
The following is a structure template: struct box { char maker[40]; float height; float width; float length; float volume; }; a. Write a function that has a reference to a box structure as its formal argument and displays the value of each member. b. Write a function that has a reference to a box structure as its formal argument and sets the volume member to the product of the other three dimensions.
DATA STRUCTURE C++ LANGUGAE Create a notepad that allows the user to write text (char by...
DATA STRUCTURE C++ LANGUGAE Create a notepad that allows the user to write text (char by char) on the console. For this purpose, the user should be able to control and track the movement of the cursor. The user should be able to navigate to any part of console (cursor control) in order to perform any insertion or deletion of words. Internally, the notepad is composed of two-dimensional linked list (every node should comprise of data element (char) and 4...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT