In this lab you will work with processing an array of structs for keeping track of a soccer league. First define a struct called SoccerPlayer. It should have 2 fields – a string to hold the name of the player, and a numeric value to hold the number of goals scored. Next define a second struct called SoccerTeam. It should have 3 fields – a string to hold the name of the team, a variable to hold the total number of games played, and an array of SoccerPlayer (with 5 elements) to store the players who play on the team who have scored goals.
In main, declare an array of SoccerTeam structures with 4 elements (4 different teams). This array should be initialized to set all the string fields to “NONE”, and the numeric fields to zero. Remember initialization means to declare and assign values to the array all in one statement (i.e. no for loops, etc.).
Your number of teams and your number of players should be declared as global constants.
NOTE: All numeric entries MUST be tested to assure that the value entered is greater than or equal to zero. Any value entered that is less than zero must have an appropriate error message and the ability to reenter the value.
Next call a function from main with the following prototype:
void showStats(SoccerTeam team[], bool);
This function should printout the contents of the initialized array on the screen. It should also calculate the average number of goals scored by each player. The average number is the total goals divided by the games played. If the number of games played is zero, the function should print out “No Games Played” for the average number of goals.
Next call a function from main with the following prototype:
void getTeamInfo(SoccerTeam team[]);
This function should allow the user to enter values into the array for every player who has scored a goal for the team. Every team has at least one player who scored a goal. But, not every team had all 5 players who scored a goal. If the user types “NONE” or “none” for one of the player names, this means that the team has less than 5 players who scored a goal. The user should not be prompted to enter any more information about any player on the team.
Next, call the showStats function again from main to display the user’s input on the screen.
EXTRA CREDIT: When showStats is called after the data entry, instead of showing all 5 players (even if there are players who have not scored a goal), only show the players who have scored a goal. In other words, instead of showing all five elements of the SoccerPlayer array, only show those players who number of goals are greater than zero. See the output below for the regular credit versus extra credit output. Remember, for the extra credit, this function needs to show ALL of the teams and players immediately after initialization. They only have to limit the display after data entry.
EXTRA CREDIT (2): Instead of the entry stopping when “NONE” or “none” are entered, the program should check for ANY combination of the letters that spell none and stop. So, NONE, none, None, NoNe, NonE, etc. would all cause the entry to stop.
Why Work with Us
Top Quality and Well-Researched Papers
We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.
Professional and Experienced Academic Writers
We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.
Free Unlimited Revisions
If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.
Prompt Delivery and 100% Money-Back-Guarantee
All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.
Original & Confidential
We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.
24/7 Customer Support
Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.
Essays
No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.
Admissions
Admission Essays & Business Writing Help
An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.
Reviews
Editing Support
Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.
Reviews
Revision Support
If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.