I forgot to attach the program. sorry for confusion. -------------Kris Gibson------------ [EMAIL PROTECTED] [EMAIL PROTECTED] [EMAIL PROTECTED]
/**************************************************** * * Programmer: Kris Gibson * * Student ID: --------- * * Grader Division and Section: 07/03 * * Project #: 2 * * Program Description: 1: Prints out a chart of teams. * 2: Takes 3 different inputs (team_number, wins, losses) * and prints out the Team name, and then * the Stats of the team with winning percentage. * The program then decides if the team has a winning, * a losing, or an even record. It then exits. * If the user uses the wrong numbers for team_number, * the program redisplays the chart and starts over. * 3: During this, it takes a tally of the number * of entries, wins, and losses and also calculates * the winning percentage. It then prints it out * when the user quits. ****************************************************/ #include <stdio.h> void chart(void); void doreport(int , int , int ); void dototals(int, int, int *, int *, int *, char); char getanswer(void); void main(void) { int team, wins, loss, tot_team= 0, tot_wins= 0, tot_loss= 0; char more; do { chart(); printf("\n\n Enter the team number from the chart, along with"); printf("\n the number of victories and losses on the same line. "); scanf("%d %d %d",&team,&wins,&loss); fflush(stdin); if (team < 1 || team > 11) printf("\n\n Look at the chart again. Here it is:\n\n"); else { doreport(team, wins, loss); /* Print out stats */ more = getanswer(); /* Ask user if want to continue */ /* Do some tallying */ dototals(wins, loss, &tot_team, &tot_wins, &tot_loss, more); } } while (team < 1 || team > 11 || more == 'Y' || more == 'y'); } /* Keep going when "team" is invalid, or if user wants to continue */ /**************************************************** * * Function Information * * Name: doreport * * Type: void * * Parameters: int t, int w, int l * * Function Description: This function does 3 things: * 1: It uses a switch to pick which team of * the Big Ten using "team_number," and prints it. * 2: It then prints out the wins, losses and * the winning percentage stats of the team. * 3: Finally, it decided if the team has a losing * record, winning record, or an even record and * prints it out. * ****************************************************/ void doreport(int t,int w,int l) { printf("\n\n For "); switch (t) { case 1 : printf("The University of Illinois:"); break; case 2 : printf("Indiana University:"); break; case 3 : printf("University of Iowa:"); break; case 4 : printf("The University of Michigan:"); break; case 5 : printf("Michigan State University:"); break; case 6 : printf("The University of Minnesota:"); break; case 7 : printf("Northwestern University:"); break; case 8 : printf("The Ohio State University:"); break; case 9 : printf("Penn State University:"); break; case 10: printf("Purdue University:"); break; case 11: printf("The University of Wisconsin:"); } printf("\n\n WINS LOSSES WINNING PERCENTAGE"); printf("\n ---- ------ ------- ----------"); printf("\n\n %2d %2d %1.3f",w,l,(float)w/(l + w)); if (w > l) printf("\n\n This is a WINNING record!\n\n\n"); else if (w == l) printf("\n\n This IS an even record!\n\n\n"); else printf("\n\n This is a LOSING record!\n\n\n"); } /**************************************************** * * Function Information * * Name: chart * * Type: void * * Parameters: void * * Function Description: Prints out a display * of the 11 teams of the Big 10 along with * a small description before it. * ****************************************************/ void chart() { printf("\n\n The following list shows the corresponding number\n"); printf(" [integer (1-11)] of the universitites in the Big 10.\n\n"); printf(" 1 Illinois.\n"); printf(" 2 Indiana.\n"); printf(" 3 Iowa.\n"); printf(" 4 Michigan.\n"); printf(" 5 Michigan State.\n"); printf(" 6 Minnesota.\n"); printf(" 7 Northwestern.\n"); printf(" 8 Ohio State.\n"); printf(" 9 Penn State.\n"); printf(" 10 Purdue.\n"); printf(" 11 Wisconsin.\n\n\n"); } /**************************************************** * * Function Information * * Name: getanswer * * Type: char * * Parameters: void * * Function Description: This asks the user if they want * want to continue having 'Y' or 'y' * being the valid continue input. * ****************************************************/ char getanswer() { char more; printf("\n\nDo you wish to enter another team?\n"); printf("Enter Y or y for yes. Anything else to quit: "); scanf("%c",&more); fflush(stdin); return more; } /**************************************************** * * Function Information * * Name: dototals * * Type: void * * Parameters: int w, int l, int *tot_team, int *tot_wins, * int *tot_loss, char more * * Function Description: This function does a tally of the * total number times (tot_team), wins, * and losses using pointer parameters. * If the user did not input a 'Y' or 'y' * earlier in the program in main(), then * a tally chart is printed out with a * a winning percentage calculated between * all of the teams entered during the session. * ****************************************************/ void dototals(int w, int l,int *tot_team, int *tot_wins, int *tot_loss, char more) { (*tot_team)++; *tot_wins += w; *tot_loss += l; if (more != 'Y' || more != 'y') { printf("\n\n\n For the %d teams you entered, there were\n", *tot_team); printf("\n\n WINS LOSSES WINNING PERCENTAGE"); printf("\n ---- ------ ------- ----------"); printf("\n\n %2d %2d %1.3f",*tot_wins,*tot_loss, (float)*tot_wins/(*tot_loss + *tot_wins)); if (*tot_wins > *tot_loss) printf("\n\n This is a WINNING record!\n\n\n"); else if (*tot_wins == *tot_loss) printf("\n\n This is an EVEN record!\n\n\n"); else printf("\n\n This is a LOSING record!\n\n\n"); } }