Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write a program that declares a struct to store the data of a football player ( player s name, player s position, number of touchdowns,
Write a program that declares a struct to store the data of a football player players name, players position, number of touchdowns, number of catches, number of passing yards, number of receiving yards, and the number of rushing yards
Declare an array of components to store the data of football players.
Your program must contain a function to input data and a function to output data. Add functions to search the array to find the index of a specific player, and update the data of a player. You may assume that the input data is stored in a file. Before the program terminates, give the user the option to save data in a file. Your program should be menu driven, giving the user various choices.
I currently have the code below written up but it keeps saying its wrong so i dont know what to change.
using namespace std;
struct Player
string name;
string position;
int touchDowns;
int catches;
int passingYards;
int receivingYards;
int rushingYards;
;
void inputDataPlayer int;
void outputDataPlayer int;
int searchPlayer int, string;
void updatePlayer int, int;
void saveDataPlayer int;
int main
const int SIZE ;
Player playersSIZE;
int choice;
int index;
string name;
inputDataplayers SIZE;
do
cout "Select one of the following options: endl;
cout : To print a player's data" endl;
cout : To print the entire data" endl;
cout : To update a player's touch downs" endl;
cout : To update a player's number of catches" endl;
cout : To update a player's passing yards" endl;
cout : To update a player's receiving yards" endl;
cout : To update a player's rushing yards" endl;
cout : To quit the program" endl;
cin choice;
switch choice
case :
cout "Enter player's name: ;
cin name;
index searchplayers SIZE, name;
if index
cout "Player not found" endl;
else
cout "Name: playersindexname endl;
cout "Position: playersindexposition endl;
cout "Touch Downs: playersindextouchDowns endl;
cout "Number of Catches: playersindexcatches endl;
cout "Passing Yards: playersindexpassingYards endl;
cout "Receiving Yards: playersindexreceivingYards endl;
cout "Rushing Yards: playersindexrushingYards endl;
break;
case :
outputDataplayers SIZE;
break;
case :
case :
case :
case :
case :
cout "Enter player's name: ;
cin name;
index searchplayers SIZE, name;
if index
cout "Player not found" endl;
else
updateplayers index, choice;
break;
case :
char saveChoice;
cout "Would you like to save data? yYnN: ;
cin saveChoice;
if saveChoice y saveChoice Y
saveDataplayers SIZE;
break;
default:
cout "Invalid choice" endl;
while choice ;
return ;
void inputDataPlayer players int size
ifstream inFileChExData.txt;
if inFile
cerr "Error opening input file." endl;
exit; Exit with an error code
for int i ; i size; i
inFile playersiname;
inFile playersiposition;
inFile playersitouchDowns;
inFile playersicatches;
inFile playersipassingYards;
inFile playersireceivingYards;
inFile playersirushingYards;
inFile.close;
void outputDataPlayer players int size
for int i ; i size; i
cout "Name: playersiname endl;
cout "Position: playersiposition endl;
cout "Touch Downs: playersitouchDowns endl;
cout "Number of Catches: playersicatches endl;
cout "Passing Yards: playersipassingYards endl;
cout "Receiving Yards: playersireceivingYards endl;
int searchPlayer players
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started