(C++) Write a program that declares a struct to store the data of a football player (player’s name, player’s 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 10 components to store the data of 10 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 up-date 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.
The name of the data filename provided is Ch9_Ex7Data.txt
An example of the program is shown below:
Select one of the following options: 1: To print a player's data 2: To print the entire data 3: To update a player's touch downs 4: To update a player's number of catches 5: To update a player's passing yards 6: To update a player's receiving yards 7: To update a player's rushing yards 99: To quit the program 1 Enter player's name: Bill Name: Bill Position: Quarter_Back; Touch Downs: 70; Number of Catche s: 0; Passing Yards: 8754; Receiving Yards: 0; Rushing Yards: 573 Select one of the following options: 1: To print a player's data 2: To print the entire data 3: To update a player's touch downs 4: To update a player's number of catches 5: To update a player's passing yards 6: To update a player's receiving yards 7: To update a player's rushing yards 99: To quit the program 99 Would you like to save data: (y,Y/n,N) N
#include<iostream>
#include<string>
#include<fstream>
#include<iomanip>
using namespace std;
struct players
{
char name[20], position[50];
int touchdowns, catches, passingyards, receivingyards, runningyards;
};
void printmenu()
{
system("CLS");
cout<<"Select one of the following option"<<endl;
cout<<" 1: To print a player's data";<<endl;
cout<<"2: To print entire data";<<endl;
cout<<" 3: To update a player's touch down";<<endl;
cout<<"4: To update a player's numbers of catches";<<endl;
cout<<"5: To update a player's passing yards";<<endl;
cout<< "6: To update player's receiving yards";<<endl;
cout<< "7: To update a player's rushing yards";<<endl;
cout<<"99: To quit the program";<<endl;
}
void printdata(struct playerss[], int size)
{
int i;
for(i=1;i<10;i++)
{
cout<<"*******************";
cout<<"\nName: "<<s[i].name;
cout<<"\nPosition: "<<s[i].position;
cout<<"\nTouchdowns: "<<s[i].touchdown;
cout<<"\nCatches: "<<s[i].catches;
cout<<"\nPassing Yards: "<<s[i].passingyards;
cout<<"\nReceiving yards: <<s[i].receivingyards;
cout<<"\nRushig yards: <<s[i].rushingyards;
cout<<"\n************"<<endl;
}
void searchNamestr(struct players s[], int size, string
searchName)
{
cout << "Enter the name of the player: ";
cin >> searchName;
int flag = 0; // set flag to off
for (int i = 1; i < 10; i++) // start to loop
through the array
{
if (s[i].name == searchName) // if
match is found
{
flag = 1; //
turn flag on
break; // break
out of for loop
}
}
for (int i = 0; i<10; i++)
if (flag) // if flag is TRUE
(1)
{
cout <<
"The number of touchdowns " << s[i].touchdowns << ".\n"
<< "The Number of catches: " << s[i].catches <<
endl;
}
else
{
cout <<
"Sorry, I could not find that player in this array." << endl
<< endl;
}
}
int main()
{
int i,choice, notquit = 1;
ifstream infile;
string searchName;
bool found = false;
int index;
infile.open("ch9_Ex7Data.txt");
struct players s[10];
for (i = 1; i < 10; i++)
{
infile >> s[i].name
>> s[i].position >> s[i].touchdowns >>
s[i].catches >> s[i].passingYards >>
s[i].receivingYards >> s[i].runningYards;
}
while (notquit)
{
printmenu();
cin >> choice;
switch (choice)
{
case 1:printData(s,10);
system("pause");
break;
case 2:
searchNamestr(s,10, searchName
);
system("pause");
break;
case 3:
system("pause");
break;
case 0: notquit = 0;
break;
default:
cout <<
"Wrong entry, please try again" << endl;
system("pause");
}
}
infile.close();
// step 5
- close input file
system("pause");
return 0;
}
(C++) Write a program that declares a struct to store the data of a football player...
In C++: Functions to include: editPlayer: is a void fn, which takes an array of playerType and calls lookUpPlayer which returns the index of the target (-1 if not found). If found allows the user to edit any of the data members of the player via a menu system. lookUpPlayer: is a int fn, which takes an array of playerTypes, prompts the user for the name of the player and attempts to find them. If found, prints message "found" and...
Java 7.17 Clone of LAB*: Program: Soccer team roster This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0-99, but this is NOT enforced by the program nor tested) and the player's rating (1-9, not enforced like jersey numbers). Store the jersey numbers in one int array and the ratings in another int...
5.19 Ch 5 Program: Soccer team roster (Vectors) (C++) This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int vector and the ratings in another int vector. Output these vectors (i.e., output the roster). (3 pts) Ex:...
In C Program This program will store the roster and rating information for a soccer team. There will be 3 pieces of information about each player: Name: string, 1-100 characters (nickname or first name only, NO SPACES) Jersey Number: integer, 1-99 (these must be unique) Rating: double, 0.0-100.0 You must create a struct called "playData" to hold all the information defined above for a single player. You must use an array of your structs to to store this information. You...
5.22 LAB*: Program: Soccer team roster steam This program will store roster and rating information for a soccer team Coaches rate players during tryouts to ensure (1) Prompt the user to input five pairs of numbers: A player's jersey number (0.99) and the player's rating (1-9) Store in one int array and the ratings in another int array Output these arrays (e. output the roster) (3 pts) numbers EX Enter player 1 jersey number: Enter player l's rating: Enter player...
c++ A menu-driven program gives the user the option to find statistics about different baseball players. The program reads from a file and stores the data for ten baseball players, including player’s team, name of player, number of homeruns, batting average, and runs batted in. (You can make up your data, or get it online, for example: http://espn.go.com/mlb/statistics ) Write a program that declares a struct to store the data for a player. Declare an array of 10 components to...
Football Game Scores Write a C++ program that stores the following data about a football game in a structure: Field Name Description visit_team string (name of visiting team) home_score int visit_score int The program should read the number of games from a data file named “games.txt”, dynamically allocate an array of structures for the games using one structure for each game, and then read the information for each game from the same file (visiting team, home score, visiting team’s score)....
In c++ Write a program that contains a class called Player. This class should contain two member variables: name, score. Here are the specifications: You should write get/set methods for all member variables. You should write a default constructor initializes the member variables to appropriate default values. Create an instance of Player in main. You should set the values on the instance and then print them out on the console. In Main Declare a variable that can hold a dynamcially...
Write a program to Simulate a game of tic tac toe. A game of tic tac toe has two players. A Player class is required to store /represent information about each player. The UML diagram is given below.Player-name: string-symbol :charPlayer (name:string,symbol:char)getName():stringgetSymbol():chargetInfo():string The tic tac toe board will be represented by a two dimensional array of size 3 by 3 characters. At the start of the game each cell is empty (must be set to the underscore character ‘_’). Program flow:1) ...
Need done in C++ Can not get my code to properly display output. Instructions below. The code compiles but output is very off. Write a program that scores the following data about a soccer player in a structure: Player’s Name Player’s Number Points Scored by Player The program should keep an array of 12 of these structures. Each element is for a different player on a team. When the program runs, it should ask the user...