urgent

Discussion in 'Programming' started by rock2010, May 20, 2008.

  1. #1
    hi everybody

    i need your help to do this program plz

    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.

    Note:

    1. Every part must be written as a Function
     
    rock2010, May 20, 2008 IP
  2. solutionsystem

    solutionsystem Member

    Messages:
    73
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    48
    #2
    it is paid job? please confirm
     
    solutionsystem, May 20, 2008 IP
  3. it career

    it career Notable Member

    Messages:
    3,562
    Likes Received:
    155
    Best Answers:
    0
    Trophy Points:
    270
    #3
    That is lot of homework out there, unless you put some effort in coding it yourself no one will be ready to help you.
     
    it career, May 21, 2008 IP
  4. rock2010

    rock2010 Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    it is not a paid job

    i want you now to help me in the first step, how can i read clubs` names from a file
    ?
     
    rock2010, May 21, 2008 IP
  5. rock2010

    rock2010 Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    this is my code, can you check it for me guys


    #include <stdio.h>
    #include <string.h>
    #define size 25
    void get_s(int n[],char s1[],char s2[],int s1g[],int s2g[],int s1c[],int s2c[]);

    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)

    printf("%d",n[0]);
    else if(strcmp(s2,s_name) == 0)

    printf("%d",n[1]);

    }


    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");
    }


    if(a==3){

    for(i=0;i<size;i++){
    if(s1g>s2g)
    w1=w1+1;
    if(s2g>s1g)
    w2=w2+1;}

    if(w1>w2){
    printf("%d ",n[0]);
    for(i=0;i<size;i++)
    printf("%d",s1c);}

    else if (w2>w1){
    printf("\n%d ",n[1]);
    for(i=0;i<size;i++)
    printf("%d",s2c);}

    else
    printf ("draw");
    w1=0;
    w2=0 ;

    }



    if(a==4){

    for(i=0;i<size;i++){
    if(s1g>s2g)
    w1=w1+1;
    if(s2g>s1g)
    w2=w2+1;
    else
    draw=draw+1;}

    for(i=0;i<size;i++){
    g1=g1+s1g;
    g2=g2+s2g;}

    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);

    printf("enter the scores of teams ");
    for(i=0;i<size;i++)
    scanf("%d",&s3g); }



    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);

    printf ("\nenter the scores for team2: ");
    for(i=0;i<size;i++)
    scanf("%d",&s2c);


    printf ("\nenter the scores for team3: ");
    for(i=0;i<size;i++)
    scanf("%d",&s3c);
    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);

    printf("code of team : ");
    for(i=0;i<size;i++)
    scanf("%d",&s_c2);

    for(i=0;i<size;i++)
    if(s1c==s_c[i]&&s2c[i]==s_c2[i]){

    for(i=0;i<size;i++){
    if(s1g[i]>s2g[i])
    w1=w1+1;
    if(s2g[i]>s1g[i])
    w2=w2+1;
    else
    draw=draw+1; }

    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 ");

    scanf("%d",a); }}
    return 0; }


    void get_s(int n[],char s1[],char s2[],int s1g[],int s2g[],int s1c[],int s2c[]){

    char score;
    FILE *in;
    int i,n1;


    in = fopen("data.txt", "r");
    n[0]=fscanf(in, "%d", &n1);
    s1[0] = fscanf(in, "%c", &score);

    for(i=0;i<size;i++)


    s1[i] = fscanf(in, "%c", &score);




    n[1]=fscanf(in, "%d", &n1);
    s2[0] = fscanf(in, "%c", &score);
    for(i=0;i<size;i++)
    s2[i] = fscanf(in, "%c", &score);

    for(i=0;i<size;i++)

    s1g[i]= fscanf(in, "%d", &n1);


    for(i=0;i<size;i++)
    s2g[i]= fscanf(in, "%d", &n1);



    for(i=0;i<size;i++)

    s1c[i]= fscanf(in, "%d", &n1);


    for(i=0;i<size;i++)
    s2c[i]= fscanf(in, "%d", &n1);





    fclose(in);

    }[/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i][/i]
     
    rock2010, May 23, 2008 IP
  6. JenniP

    JenniP Peon

    Messages:
    250
    Likes Received:
    15
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Dont they teach people how to program anymore.

    No idea if it works my eyes just started swimming.

    Anyway according to your spec it doesnt meet it, you havent written it using functions.

    From a personal style point of view :-

    The variable names dont mean anything, they should really describe what they mean. This makes it much easier to read.

    You should split up the code into small functions each function should have a name that says what it does.

    Space bars really help readablity

    IE What would you prefer to read

    for(i=0;i<size;i++){

    or

    for(i = 0; i < size; i++)
    {

    Indent your code to make it more readable

    for(i=0;i<size;i++){
    if(s1g>s2g)
    w1=w1+1;
    if(s2g>s1g)
    w2=w2+1;}

    Looks much better and is more understandable as

    for(i = 0; i < size; i ++)
    {
    if(s1g > s2g)
    w1 = w1 + 1;

    if(s2g > s1g)
    w2 = w2 + 1;
    }
     
    JenniP, May 23, 2008 IP
  7. rock2010

    rock2010 Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #7
    you didn`t help, thanks!!
     
    rock2010, May 23, 2008 IP
  8. SuperEx

    SuperEx Banned

    Messages:
    106
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #8
    ur budget ?????
     
    SuperEx, May 24, 2008 IP
  9. rock2010

    rock2010 Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    what are you saying ?!!!!
     
    rock2010, May 24, 2008 IP
  10. rock2010

    rock2010 Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #10
    nobody wants to help!!, why are you opening this forum then ??!
     
    rock2010, May 25, 2008 IP
  11. fernan

    fernan Well-Known Member

    Messages:
    127
    Likes Received:
    14
    Best Answers:
    0
    Trophy Points:
    125
    #11
    just curious... how about php?
     
    fernan, May 25, 2008 IP
  12. rock2010

    rock2010 Peon

    Messages:
    20
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    i need someone helping, not making useless comments
     
    rock2010, May 25, 2008 IP