Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This is a sample computer program in C output of one teams score of 13 points in

ID: 3721032 • Letter: T

Question


This is a sample computer program in C output of one teams score of 13 points in a football game with all different scenarios once the program is compiled.

I need to compile a computer program in C that will output the same exact output as the sample above. How do I get this same exact output? The possible scenarios of scoring are; touchdown =6, point after touchdown =1, two-point conversion =2, safety=2, and field goal = 3 points.

Please input a score 0-99 for a team in a football game: 13 Score | Number of scenarios | Number of Searches 13 For a score of 13, 10290 searches are used to find 7 different scenarios: Case Touchdown | PAT | 2-pt Conversion Field Goal | safety | Score 10290 13 13 13 13 13 13 13 Press Enter to return to Quincy...

Explanation / Answer

#include <stdio.h>

#include <string.h>

#include <stdlib.h>

  

#define MAXTEAMS 20   

  

  

  

struct league{   

char teamName[50];

char name[50];

int teamScore;

int team2Score;

int totNoTeams;

int points;

int team1Points;

int team2Points;

int goalsFor;

int goalsAgainst;

int played;

int won;

int lost;

int drawn;

};

  

void displayLeagueTable(struct league records[]);

void addTeam(struct league records[]);

void getTeam(struct league records[]);

void addResults(struct league records[]);

char displayMenu(void);   

  

  

  

  

  

int main(void)

{

  

struct league table[MAXTEAMS];   

char option;

  

do

{

option = displayMenu();

  

switch(option)

{

case 'a': getTeam(table),addTeam(table);

break;

case 'b': addResults(table);

break;

case 'c': displayLeagueTable(table);

break;

case 'd': //calculateResult(table);

break;

case 'e': break;

}

}while(option != 'e');

  

return 0;

}

  

char displayMenu(void)

{

char selection = 'X';

  

printf("a Add New Team ");   

printf("b Add Match Results ");

printf("c Display League Table ");

printf("d calculate Result ");

printf("e Exit ");

  

printf(" Selection");   

scanf("%c", &selection);

fflush(stdin);

  

while(selection != 'a' && selection != 'b' && selection != 'c'

&& selection != 'd' && selection != 'e')

{

printf(" ERROR, Select choices between a-g: ");

scanf("%c", &selection);

fflush(stdin);

}

  

return selection;

}

  

  

  

void getTeam(struct league records[])

{

int i;

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

{

printf("Add new Team: ");

scanf("%s", &records[i].name);

fflush(stdin);

}

}

  

void addTeam(struct league records[])

{

int i;

  

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

{

  

records[i].teamScore = 0;

records[i].team2Score = 0;

records[i].points = 0;

records[i].team2Points = 0;

records[i].goalsFor = 0;

records[i].goalsAgainst = 0;

records[i].played = 0;

records[i].won = 0;

records[i].lost = 0;

records[i].drawn = 0;

  

}

}

  

  

void addResults(struct league records[])

{

  

int i;

  

for ( i = 0; i < MAXTEAMS-1; i++)

  

{

printf("Home team is: %s ", records[i].name);

  

printf("Enter Home teams score: ");

scanf("%d", &records[i].teamScore);

fflush(stdin);

  

printf("Away team is: %s ", records[i+1].name);

  

printf("Enter Away teams score: ");

scanf("%d", &records[i+1].teamScore, i++);

fflush(stdin);  

  

if (strcmp(records[i+1].name, (records[i].name)) == 0)

printf("Sorry teams Cannot play each other");

}

}

  

  

void displayLeagueTable(struct league records[])

{

int i;

  

for ( i = 0; i < MAXTEAMS-1; i++)

{

if (records[i+1].teamScore > records[i].teamScore)

{

records[i+1].points += 3;

records[i+1].won ++;

records[i+1].played;

records[i].won ;

records[i].lost++;

records[i].points =0 ;

records[i].played++;

  

}

if (records[i].teamScore > records[i+1].teamScore)

{

records[i].points +=3;

records[i].won ++;

records[i].played++;

records[i+1].lost++;

records[i+1].points = 0;

records[i+1].played++;

  

}

  

if (records[i].teamScore == records[i+1].teamScore)

{

records[i].points += 1;

records[i].drawn ++;

records[i].played++;

records[i+1].drawn++;

records[i+1].points += 1;

records[i+1].played++;

}

  

printf(" LeagueTable ");

printf("********************************************************** ");

printf("Team Played Won Drawn Lost For Agst Points ");

printf("*********************************************************** ");

}

  

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

{

printf("%s %d %d %d %d %d %d %d ",

records[i]. name, records[i].played, records[i].won,records[i].drawn,

records[i]. lost, records[i].goalsFor, records[i].goalsAgainst,

records[i].points);

}

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote