hello everybody, can you help me writing this program
Develop a system that inputs football match statistics. We will need to use arrays for this program. These arrays will be stored in a file. These arrays will contain the following information:
1) Teams
Team_code Team_name
2) Scores
Team_a_goals Team_b_goals
3) Matches
Team_a_code Team_b_code
display a menu with the following options:
1. Find the team number
2. Find the team name
3. Display team List
4. Show team Stats
5. Enter new team
6. Enter new match score
7. Edit old match score
8. Display stats of matches between 2 teams
9. Quit
Save the arrays into the file upon exit from the menu.
Upon execution of each menu item, you will have to return to the main menu. There is only one way out of program and that is when user presses option 9 to explicitly quit from the program
• In option 1, you shall ask team name and display team number.
• In option 2, you shall ask team number and display team name.
• In option 3, you shall display teams list in accordance with their match performance i.e team with most wins will displayed first and in this manner all the teams will be displayed in accordance with their number of wins in descending order. In this list only team code and team number shall be displayed.
• In option 4, you shall show team no, name, number of wins, number of loses and draws, total goals scored and total goals scored against.
• In option 5, you shall ask for team code and team name and then add this team in team table.
• In option 6, you shall ask for the codes of both teams and scores of each team in the match.
• In option 7, you shall ask whether the user wants to edit scores or team codes and then edit likewise. After editing ask user if he wants to edit any other entry , if user answers in yes then let him edit again otherwise proceed to main menu.
(
For those of you, who have not implemented the above condition.
• In option 7, you shall ask the user to enter the new goals of both teams and then overwrite the previous score with the new one. After editing ask user if he wants to edit any other entry, if user answers in yes then let him edit again otherwise proceed to main menu.
)
• In option 8, you shall ask for the codes of two teams and then will display total number of matches played between two teams and total number of wins / losses / draws of each team against another.
• In option 9, you shall make sure that user really wants to quite by displaying a message. If user confirms then quit otherwise lead him to main menu.
Precaution
1) No invalid team code should be stored in Matches array.(i.e code that is not present in Teams table.).
2) No invalid score should be stored in Score table like any negative number.
3) Every entry of Matches table is related to the corresponding entry of the Scores table. i.e. entry 1 of Matches table is related to entry 1 of Scores table. It means that match represented by entry 1 in Matches table has score represented by entry 1 of Scores table.
Hi, as with your previous posts, you need to do the first bit of work yourself then others will be happy to help you build on that.
Try just writing the code to display the menu and input the users selection from the menu. Add the code to call a different function for each selection but in each function just output the function purpose and 'Comming soon' or similar.
Remember to include functions for loading the data (which can simply output 'Loading Data' for now), and your first try at declaring the data structures to hold the data.
i will post what i finished soon, but how can i read team names frome a file, i can read numbers buti have no idea about names , can you help me please?!
See http://www.cplusplus.com/doc/tutorial/files.html for details on reading data from files - it gives an example which reads a line of text at a time. You should be able to use that as the basis for reading a Team_Code Team_Name line, and then split that into the two parts once you have read it.
int main (){
char s1[size],s2[size],chooce[8],s_name[size],s3[size];
int n[size],s1g[size],s2g[size],s3g[size],s1c[size],s2c[size],s3c[size],i,w1,w2,draw,g1,g2,a,number,s_c[size],s_c2[size], ans;
get_s(n,s1,s2,s1g,s2g,s1c,s2c);
printf("1. Find the team number\n2. Find the team name\n3. Display team List\n4. Show team Stats\n5.Enter new team \n6. Enter new match score\n7.Edit old match score\n8.Display stats of matches between 2 teams\n9. Quit ");
scanf("%d",a);
while (a!=0){
if (a==1){
printf("Enter the team name ");
gets(s_name);
if (strcmp(s1,s_name) == 0)
if (a==2){
printf("Enter the team number ");
scanf("%d",&number);
if(number==n[0])
puts(s1);
else if (number==n[1])
puts (s2);
else printf("number DNE");
}
printf("%d ",n[0]);
puts(s1);
printf("\nnumber of wins= %d \n number of loses= %d \n number of draws= %d \n number of goals scored= %d \n number of goals scored against= %d",w1,w2,draw,g1,g2);
printf("\n\n");
printf("%d ",n[1]);
puts(s2);
printf("\nnumber of wins= %d \n number of loses= %d \n number of draws= %d \n number of goals scored= %d \n number of goals scored against= %d",w2,w1,draw,g2,g1);
}
if(a==5){
printf("enter the team name and number");
gets(s3);
scanf("%d",&n[2] );
}
if(a==6){
printf("enter the code of teams ");
for(i=0;i<size;i++)
scanf("%d",&s3c[i]);
printf("enter the scores of teams ");
for(i=0;i<size;i++)
scanf("%d",&s3g[i]); }
if(a==7){
ans=1;
while(ans==1)
{
printf("Enter the new scores for both teams ");
printf ("\nenter the scores for team1: ");
for(i=0;i<size;i++)
scanf("%d",&s1c[i]);
printf ("\nenter the scores for team2: ");
for(i=0;i<size;i++)
scanf("%d",&s2c[i]);
printf ("\nenter the scores for team3: ");
for(i=0;i<size;i++)
scanf("%d",&s3c[i]);
printf("do you want to edit any more scores ?");
gets(chooce);
if(chooce[0]=='y'&&chooce[1]=='e'&&chooce[2]=='s')
ans=1;
else
ans=0;
}
if (a==8){
printf("enter the codes of two teams");
printf("code of team 1: ");
for(i=0;i<size;i++)
scanf("%d",&s_c[i]);
printf("code of team : ");
for(i=0;i<size;i++)
scanf("%d",&s_c2[i]);
printf("for team 1 %d %d %d %d",size,w1,w2,draw);
printf("\n for team 2 %d %d %d %d",size,w2,w1,draw);
} }
if (a==9){
printf("are you sure you want to exit ");
scanf("%s",&chooce);
if(chooce[0]=='y'&&chooce[1]=='e'&&chooce[2]=='s')
a=0;
}
printf("1. Find the team number\n2. Find the team name\n3. Display team List\n4. Show team Stats\n5.Enter new team \n6. Enter new match score\n7.Edit old match score\n8.Display stats of matches between 2 teams\n9. Quit ");
I don't think you can blame anyone on this formum for not wanting to help.
You have not posted your question in a well thought-out manner.
You have not posted your code in the correct [c0de] [/c0de] (replace 0 with o) tags as described http://www.cplusplus.com/forum/articles/1624/
If you format your code, and ask questions correctly you will find people are much more willing to help.
1. End Brace for the if(a==7){ is after scanf("%d",a); }}, correct the same.
2. scanf("%d",a); should be scanf("%d",&a);.
3. U may need to fflush the stdin before gets(....)
Also please state UR exact problem so that somebody can give U the solution to get rid of that problem.
EDIT:
If U would have used "#" button to post the code then it would be helpful in stating the problem at the particular line number....
thanks DiptenduDas for help but it is exactly as our instructor send it to us i didn`t understand some orders so i posted it to you because i have been sending him messages since last week and he doesn`t reply.
so please if you can help me more, i will be grateful