GIDForums  

Go Back   GIDForums > Computer Programming Forums > C Programming Language
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 16-Jul-2009, 14:01
Pefectionist Pefectionist is offline
New Member
 
Join Date: Jul 2009
Posts: 4
Pefectionist is on a distinguished road

How to get a head start on this?


I'm kinda stuck with how to start this code. Well. most stuck with how to make a table and all really

Write a program that displays the scores of the basket balls games for 1 season.
The table should include the following information ( in separate columns),
name of the basket ball league,
number of games played in the season by the group,
number of winning games, percent of winning games (with respect to the total games played).
The inputs do not have to be from real life
You have to include at least 4 different rows in the table, namely 4 different leagues .
You can read the inputs from the user or build the table in the program itself – as you wish.
The percentage needs to be computed within the program
  #2  
Old 16-Jul-2009, 15:55
zalezog zalezog is offline
Junior Member
 
Join Date: Oct 2007
Posts: 33
zalezog will become famous soon enough

Re: How to get a head start on this?


Here's an approach

CPP / C++ / C Code:
#include<stdio.h>
#include<string.h>

struct Basketball_infobase
{
    char team_name[BUFSIZ];
    int games_played;
    int number_wins;
    double winning_percent;
};
void getdata(struct Basketball_infobase* bot)
{
    /*This function can also be extended to get user input*/ 

    strcpy(bot->team_name,"Rockets");
     bot->games_played = 20;
     bot->number_wins = 18;
    /*Calculating winning percent : wins / game played * 100  and the store it in
     bot->winning_percent = ???*/ 
}
void display_team(struct Basketball_infobase* bot)
{
    printf("\n%18s    %11d    %6d    %5.2lf",bot->team_name,
                                            bot->games_played,
                                            bot->number_wins,
                                            90.00);


}
int main(void)
{
    struct Basketball_infobase bot ;

    puts("\n*************SEASON 1**************\n");
    printf("          Team Name    Games Played    Wins    %%Win");
    getdata(&bot);
    display_team(&bot);


    return 0;
}
For 4 different leagues create 4 different bots (an array) and place it in a looping construct such that after each iteration you increment address of bot by 1.You go on storing team statistics in that struct.

Call the display_team function in same way.
CPP / C++ / C Code:
 const int MAX_SIZE = 2;
    struct Basketball_infobase bot[MAX_SIZE] ;

    int i = 0;

    for (i = 0; i < MAX_SIZE; i++)
         getdata(&bot[i]);
.
.
.
for (i = 0; i < MAX_SIZE; i++)
    display_team(&bot[i]);


Show us some code , you might get help here.
 
 

Recent GIDBlogProgramming ebook direct download available by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to find a mathematical formula for this recursion? transgalactic C Programming Language 8 12-Oct-2008 08:43
Str_Misaligned in Double Link List Peter_APIIT C Programming Language 1 29-Feb-2008 21:50
Linked list memory question dabigmooish C++ Forum 3 31-Oct-2006 01:05
Urgent ! Pls Help Me ! mycashmoney C Programming Language 4 01-Jul-2006 23:49
search linked list itsmecathys C++ Forum 20 18-Apr-2005 02:34

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 16:48.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.