# How Do I Go About Writing This Program?



## bkaron (Oct 30, 2003)

Teachers Assiment:



> Running stats for sporting events may be one of the most important position for a person to take. In baseball, a person is literally judged by the number he puts up. In football, depending on the numbers, a coach or quarterback may decide on to run or pass. What you are to do is take a previous football (one played before) and detect the quarterback's yards per carry, yards per play, touches per score, and drive efficiency.
> 
> your job is to re-create the programming logic in C++ code. You will have to use at least 3 functions and variables that will have to be passed both by value and references.



WTF I don't even know where to begin


----------



## brianleahy (Oct 30, 2003)

I could help you with the code -- _if _ I understood any of the football stuff...


----------



## bkaron (Oct 30, 2003)

Don't understand football  Where are you from    ::ha::


----------



## bkaron (Nov 3, 2003)

C'mon I really need some help on this  This program is due on Wensday!


----------



## brianleahy (Nov 3, 2003)

> What you are to do is take a previous football (one played before) and detect the quarterback's yards per carry, yards per play, touches per score, and drive efficiency.



I assume your instructor meant a previous football GAME.  No promises here but: For starters, do you have any idea how exactly you can "detect" the quarterback's yards?  I don't think there's a stdlib function to do that.  8)  

Where is the data going to come from?   Hand entered?  Read from a website?  If you don't know, that's something to ask the professor about.


----------



## wadesworld (Nov 4, 2003)

I would assume the instructor is going to give you some data file which contains all the plays and the results.  You would then parse that file and use the data to derive the statistics required.


----------



## bkaron (Nov 4, 2003)

Whats Wrong With it  (If you are going to edit the code please try and leave it the same way. What I mean is dont go all technical on me, I just started this class. a few weeks ago)


```
#include <iostream>
using namespace std;
 
  void divd (float x, float y);
  void add (float a, float b, float c);
  
int main ()

{ 
 int TotalNetRushes, Rushes;
cout << "Ok, Lets Calculate Total-Net-Rushes, Input Rushing Yards";
cin >> TotalNetRushes;
cout << "Now Input The Amount of Rushes";
cin >> Rushes; 
divd (TotalNetRushes, Rushes);
cout << "Here is Your Average Per Rush: " << x/y << endl;

 int TotalNetYards, TotalPlays;
cout << "Now Lets Try Total-Net-Yards, Input The Total Amount of Yards";
cin >> TotalNetYards;
cout << "Now Input The Amount of Plays";
cin >> TotalPlays;
divd (TotalNetYards, TotalPlays);
cout << "Here is Your Average Gain Per Play: " << x/y << endl;

 int TotalPlays, Rushes, Completions;
cout << "Ready For Touches Per Score? Input The Total Amount of Plays";
cin >> TotalPlays;
cout << "Now The Total Amount of Rushes";
cin >> Rushes;
cout << "And Completions";
cin >> Completions;
add (TotalPlays, Rushes, Completions);
cout << "Here is The Total Amount of Touches Per Score: " << a+b+c << endl;

 int Passing, Rushing, Penalty, TotalYardsForGame;
cout << "To Calculate Drive Efficiency First Input The abount of 1st Downs Obtaind By Passing";
cin >> Passing;
cout << "Now Inpuit The Downs Obtaind By Rushing";
cin >> Rushing;
cout << "Do The Same For Downs Obtaind By Penaltys";
cin >> Penalty;
cout << "Input All The Yards The Team Obtained During The Whole Game (It Should Be Something Like 339)";
add (Passing, Rushing, Penalty);
divd (TotalYardsForGame);
cout << "Here is Your Drive Efficiency: " << a+b+c/x << endl;
} 
  void divd (float x, float y);
  void add (float a, float b, float c);
```


----------



## naodx (Nov 4, 2003)

ok, first in your function main, the last line should be:

return (0);

as main returns an int value upon completion.

I would change your functions from being void to a return type of float, since that is the type of data/answer you are looking for.

A void function can use that data passed to it, but you can't change/modify the values of the variables unless you use call by reference (something you might not have covered yet).

With changing your return type on the functions, you will have to use some type of assignment to get the value you are looking for.

eg)

float add( float a, float b )
{
return ( a + b );
}

when you go to call that function with the data you want to pass it, it will look something like this.

float answer;

answer = add( a, b );

cout << answer << endl;

take a look at the sample code that I posted on your other thread, and you should get the idea on the syntax for your functions.

Good luck


----------



## bkaron (Nov 4, 2003)

Ummmm.... Could you rewright my code the way you were describing it? It's a little hard for me to understand what you are saying. Thanks.


----------



## bkaron (Nov 5, 2003)

Well I finished it, I thought you guys might like to see it


```
#include <iostream>
using namespace std;

       void divd (float x, float y)
       {cout << " --> Here is Your Average Per Rush: " << x/y << endl;
       }
       void divdd (float x, float y)
       {cout << " --> Here is Your Average Total-Net-Yards: " << x/y << endl;
       }
       void add (float a, float b, float c)
       {cout << " --> Here is The Total Amount of Touches Per Score: " << a+b+c << endl;
       }
       void addd (float a, float b, float c)
       {}  
       void divddd (float x, float y)
       {cout << " --> Here Is The Drive Efficiency: " << x/y << endl;
       }

int main ()

{cout << " ** Welcome! Do You Love Football and Don't Know Much Math? Well, You Came To The Right Place. This Program Will Calculate A Teams Total-Net-Rushes, Total-Net-Yards, Touches Per Score, and Drive Efficiency. Would You Like To Continue? (n/y): ";
     char y;
     cin >> y;
     if (y=='y')
{

float TotalNetRushes, Rushes;
     cout << " * Ok, Lets Calculate Total-Net-Rushes, Input Total Rushing Yards: ";
     cin >> TotalNetRushes;
     cout << " - Now Input The Amount of Rushes: ";
     cin >> Rushes; 
       divd (TotalNetRushes, Rushes);

float TotalNetYards, TotalPlays;
     cout << " * Now Lets Try Total-Net-Yards, Input The Total Amount of Yards: ";
     cin >> TotalNetYards;
     cout << " - Now Input The Amount of Plays: ";
     cin >> TotalPlays;
       divdd (TotalNetYards, TotalPlays);

float Completions;
     cout << " * Ready For Touches Per Score? Input The Total Amount of Plays: ";
     cin >> TotalPlays;
     cout << " - Now The Total Amount of Rushes: ";
     cin >> Rushes;
     cout << " - And Completions: ";
     cin >> Completions;
       add (TotalPlays, Rushes, Completions);

float Passing, Rushing, Penalty, TotalYardsForGame, ans;
     cout << " * To Calculate Drive Efficiency First Input The amount of 1st Downs Obtained By Passing: ";
     cin >> Passing;
     cout << " - Now Inpuit The Downs Obtained By Rushing: ";
     cin >> Rushing;
     cout << " - Do The Same For Downs Obtained By Penaltys: ";
     cin >> Penalty;
       addd (Passing, Rushing, Penalty);
     cout << " - Input All The Yards The Team Obtained During The Whole Game: ";
     cin >> TotalYardsForGame;
       divddd (ans, TotalYardsForGame);

} 
else
{cout << "********* You Suck! *********";
}
}
```


----------



## brianleahy (Nov 10, 2003)

Well let us know what sort of grade you get


----------

