matz0rz

10-19-2011, 11:53 PM

Okay, I got a good one for you coding guru's. I'm sort of a noob at coding C++ but I managed to make or partially make a NFL Game Predictor . I thought it would be a good project for me to get back in the coding game. So this is what I came up with.

#define _WIN32_WINNT 0x0500

#include <windows.h>

#include <Wincon.h>

#include <cstdlib>

#include <iostream>

using namespace std;

int main(int argc, char *argv[])

{

//Data Table

int iTeam1apy;

int iTeam2apy;

int iTeam1ary;

int iTeam2ary;

int iTeam1aya;

int iTeam2aya;

double dTeam1as;

double dTeam2as;

double dTeam1ai;

double dTeam2ai;

int iTeam1lp;

int iTeam2lp;

int iTeam1wl;

int iTeam2wl;

double dTeam1line;

double dTeam2line;

double dTeam1 = 10.0; // Home Team Gets 10.0 Points Advantage

double dTeam2;

double dTeam1p;

double dteam2p;

double dTotal;

double temp;

double Dapy = 0.5;

double Dary = 1.0;

double Daya = -1.5;

double Das = 5.0;

double Dai = 5.0;

//Full Screen Mode

HWND hWnd = GetConsoleWindow();

ShowWindow(hWnd,SW_SHOWMAXIMIZED);

//Title & Color

system("title NFL Game Predictor BETA Handicapping Software");

system("color E2");

//Instructions

cout << "Loading NFL Predictor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \n";

system("PAUSE");

system("cls");

cout << "Instructions: \n \n";

cout << "Enter all the data needed to predict the game. \n \n";

cout << "Offensive- Average Passing Yards Per Game \n \n";

cout << "Offensive- Average Rushing Yards Per Game \n \n";

cout << "Defensive- Average Yards Against Per Game \n \n";

cout << "Defensive- Average Sacks Per Game (If less than 1, devide the number of sacks by the number of games played)\n \n";

cout << "Defensive- Average Interceptions Per Game (If less than 1, devide the number of interceptions by the number of games played)\n \n";

cout << "Team- League Position \n \n";

cout << "Team- Win/Lose Streak (Must be more than 3 games) \n \n";

cout << "Sport Book- Enter the lines from your sports book \n \n";

system("pause");

system("cls");

//The Home Team

cout << "Please Enter The Data For The Home Team. \n";

cout << "Home Team Average Passing Yards Per Game? \n";

cin >> iTeam1apy;

cout << "\n";

cout << "Home Team Average Rushing Yards Per Game? \n";

cin >> iTeam1ary;

cout << "\n";

cout << "Home Team Average Yards Against Per Game? \n";

cin >> iTeam1aya;

cout << "\n";

cout << "Home Team Average Sacks Per Game? \n";

cin >> dTeam1as;

cout << "\n";

cout << "Home Team Average Interceptions Per Game? \n";

cin >> dTeam1ai;

cout << "\n";

cout << "Home Team League Position? \n";

cin >> iTeam1lp;

cout << "\n";

cout << "Home Team Win/Lose Streak? (Must Be Greater Than 3) \n";

cin >> iTeam1wl;

cout << "\n";

cout << "Home Team Sports Book Odds, Money Line? (E.g.: 1.85) \n";

cin >> dTeam1line;

cout << "\n";

system("pause");

system("cls");

// The Away Team

cout << "Please Enter The Data For The Away Team. \n";

cout << "Away Team Average Passing Yards Per Game? \n";

cin >> iTeam2apy;

cout << "\n";

cout << "Away Team Average Rushing Yards Per Game? \n";

cin >> iTeam2ary;

cout << "\n";

cout << "Away Team Average Yards Against Per Game? \n";

cin >> iTeam2aya;

cout << "\n";

cout << "Away Team Average Sacks Per Game? \n";

cin >> dTeam2as;

cout << "\n";

cout << "Away Team Average Interceptions Per Game? \n";

cin >> dTeam2ai;

cout << "\n";

cout << "Away Team League Position? \n";

cin >> iTeam2lp;

cout << "\n";

cout << "Away Team Win/Lose Streak? (Must Be Greater Than 3) \n";

cin >> iTeam2wl;

cout << "\n";

cout << "Away Team Sports Book Odds, Money Line? (E.g.: 1.85) \n";

cin >> dTeam2line;

cout << "\n";

system("pause");

system("cls");

cout << "CALCULATING ODDS .....\n";

system("pause");

system("CLS");

// The Math

// Scoring System:

// Average Passing Yards = +0.5 Points Per Yard

// Average Passing Yards = +1.0 Points Per Yard

// Average Yards Against = -1.5 Points per Yard

// Average Sacks = +5.0 Points Per Sack

// Average Interceptions = +5.0 Points Per Interception

// League Rank = (1) 50.0 Points; (2) 40.0 Points; (3) 30.0 Points; (4) 20.0 Points ...

// Win / Lose Streak = (3) +/- 20.0 Points; (4) +/- 25.0 Points; (5) +/- 30.0 Points ...

//

// Sport Book odds : If dTeam1line < dTeam2line then dTeam1 + 10.0 Points

// If dTeam2line < dTeam1line then dTeam1 - 10.0 Points

//

// Comparing The Teams: If dTeam1 > dTeam2 then dTeam1 Wins

// If dTeam2 > dTeam1 then dTeam2 Wins

//

// Calculate % for each team: dTeam1 + dTeam2 = dTotal

// dTotal / dTeam1 = dTeam1p

// dTotal / dTeam2 = dTeam2p

//

// Display Winning Team and Percantage.

// Calculating Odds.

// Team 1

temp = iTeam1apy * Dapy;

dTeam1 = temp + dTeam1;

temp = iTeam1ary * Dary;

dTeam1 = temp + dTeam1;

temp = iTeam1aya * Daya;

dTeam1 = temp + dTeam1;

temp = dTeam1as * Das;

dTeam1 = temp + dTeam1;

temp = dTeam1ai * Dai;

dTeam1 = temp + dTeam1;

//Team 2

temp = iTeam2apy * Dapy;

dTeam2 = temp + dTeam2;

temp = iTeam2ary * Dary;

dTeam2 = temp + dTeam2;

temp = iTeam2aya * Daya;

dTeam2 = temp + dTeam2;

temp = dTeam2as * Das;

dTeam2 = temp + dTeam2;

temp = dTeam2ai * Dai;

dTeam2 = temp + dTeam2;

//If Statments

//League Position

//Team 1

if (iTeam1lp == 1)

dTeam1 = dTeam1 + 50;

if (iTeam1lp == 2)

dTeam1 = dTeam1 + 40;

if (iTeam1lp == 3)

dTeam1 = dTeam1 + 30;

if (iTeam1lp == 4)

dTeam1 = dTeam1 + 20;

if (iTeam1lp == 5)

dTeam1 = dTeam1 + 10;

//Team 2

if (iTeam2lp == 1)

dTeam2 = dTeam2 + 50;

if (iTeam2lp == 2)

dTeam2 = dTeam2 + 40;

if (iTeam2lp == 3)

dTeam2 = dTeam2 + 30;

if (iTeam2lp == 4)

dTeam2 = dTeam2 + 20;

if (iTeam2lp == 5)

dTeam2 = dTeam2 + 10;

// Win/Lose Streak if statments

// Team 1

if (iTeam1wl == 3)

dTeam1 = dTeam1 + 20;

if (iTeam1wl == 4)

dTeam1 = dTeam1 + 25;

if (iTeam1wl >= 5)

dTeam1 = dTeam1 + 30;

if (iTeam1wl == -3)

dTeam1 = dTeam1 - 20;

if (iTeam1wl == -4)

dTeam1 = dTeam1 - 25;

if (iTeam1wl >= -5)

dTeam1 = dTeam1 - 30;

//Team 2 If Statments

if (iTeam2wl == 3)

dTeam2 = dTeam2 + 20;

if (iTeam2wl == 4)

dTeam2 = dTeam2 + 25;

if (iTeam2wl >= 5)

dTeam2 = dTeam2 + 30;

if (iTeam2wl == -3)

dTeam2 = dTeam2 - 20;

if (iTeam2wl == -4)

dTeam2 = dTeam2 - 25;

if (iTeam2wl >= -5)

dTeam2 = dTeam2 - 30;

// Sport Book Lines. If statments

if (dTeam1line > dTeam2line)

dTeam1 = dTeam1 + 10;

if (dTeam2line > dTeam1line)

dTeam2 = dTeam2 + 10;

// Final

cout << "Generated Score: \n";

cout << "Home Team: " << dTeam1 << "Away Team: " << dTeam2;

system("pause");

//The End

system("pause");

return EXIT_SUCCESS;

}

It compiles & runs, therefore something is wrong with the math. If you read the comment area of the code I try to explain the "Scoring System". When I ran the application to test it, I entered the data in a way that Team 1 would obviously generate a higher score, but it did not. I haven't coded in years and I'm under the impression they're many, many mistakes in this code even though it compiled. You are going to ask me "What's the ouput it's giving you and what are you expecting it to output? " ... Well it's a little hard to explain but if you look at the comment area of the code, the scoring system to be more precise, run the application and test the math, you'll notice it's not working.

Also... Using double temp; as a variable to store temporary data, does that make sence?

Please, I'm looking forward to your help and suggestions.

Kind Regards

-Mat P.

#define _WIN32_WINNT 0x0500

#include <windows.h>

#include <Wincon.h>

#include <cstdlib>

#include <iostream>

using namespace std;

int main(int argc, char *argv[])

{

//Data Table

int iTeam1apy;

int iTeam2apy;

int iTeam1ary;

int iTeam2ary;

int iTeam1aya;

int iTeam2aya;

double dTeam1as;

double dTeam2as;

double dTeam1ai;

double dTeam2ai;

int iTeam1lp;

int iTeam2lp;

int iTeam1wl;

int iTeam2wl;

double dTeam1line;

double dTeam2line;

double dTeam1 = 10.0; // Home Team Gets 10.0 Points Advantage

double dTeam2;

double dTeam1p;

double dteam2p;

double dTotal;

double temp;

double Dapy = 0.5;

double Dary = 1.0;

double Daya = -1.5;

double Das = 5.0;

double Dai = 5.0;

//Full Screen Mode

HWND hWnd = GetConsoleWindow();

ShowWindow(hWnd,SW_SHOWMAXIMIZED);

//Title & Color

system("title NFL Game Predictor BETA Handicapping Software");

system("color E2");

//Instructions

cout << "Loading NFL Predictor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . \n";

system("PAUSE");

system("cls");

cout << "Instructions: \n \n";

cout << "Enter all the data needed to predict the game. \n \n";

cout << "Offensive- Average Passing Yards Per Game \n \n";

cout << "Offensive- Average Rushing Yards Per Game \n \n";

cout << "Defensive- Average Yards Against Per Game \n \n";

cout << "Defensive- Average Sacks Per Game (If less than 1, devide the number of sacks by the number of games played)\n \n";

cout << "Defensive- Average Interceptions Per Game (If less than 1, devide the number of interceptions by the number of games played)\n \n";

cout << "Team- League Position \n \n";

cout << "Team- Win/Lose Streak (Must be more than 3 games) \n \n";

cout << "Sport Book- Enter the lines from your sports book \n \n";

system("pause");

system("cls");

//The Home Team

cout << "Please Enter The Data For The Home Team. \n";

cout << "Home Team Average Passing Yards Per Game? \n";

cin >> iTeam1apy;

cout << "\n";

cout << "Home Team Average Rushing Yards Per Game? \n";

cin >> iTeam1ary;

cout << "\n";

cout << "Home Team Average Yards Against Per Game? \n";

cin >> iTeam1aya;

cout << "\n";

cout << "Home Team Average Sacks Per Game? \n";

cin >> dTeam1as;

cout << "\n";

cout << "Home Team Average Interceptions Per Game? \n";

cin >> dTeam1ai;

cout << "\n";

cout << "Home Team League Position? \n";

cin >> iTeam1lp;

cout << "\n";

cout << "Home Team Win/Lose Streak? (Must Be Greater Than 3) \n";

cin >> iTeam1wl;

cout << "\n";

cout << "Home Team Sports Book Odds, Money Line? (E.g.: 1.85) \n";

cin >> dTeam1line;

cout << "\n";

system("pause");

system("cls");

// The Away Team

cout << "Please Enter The Data For The Away Team. \n";

cout << "Away Team Average Passing Yards Per Game? \n";

cin >> iTeam2apy;

cout << "\n";

cout << "Away Team Average Rushing Yards Per Game? \n";

cin >> iTeam2ary;

cout << "\n";

cout << "Away Team Average Yards Against Per Game? \n";

cin >> iTeam2aya;

cout << "\n";

cout << "Away Team Average Sacks Per Game? \n";

cin >> dTeam2as;

cout << "\n";

cout << "Away Team Average Interceptions Per Game? \n";

cin >> dTeam2ai;

cout << "\n";

cout << "Away Team League Position? \n";

cin >> iTeam2lp;

cout << "\n";

cout << "Away Team Win/Lose Streak? (Must Be Greater Than 3) \n";

cin >> iTeam2wl;

cout << "\n";

cout << "Away Team Sports Book Odds, Money Line? (E.g.: 1.85) \n";

cin >> dTeam2line;

cout << "\n";

system("pause");

system("cls");

cout << "CALCULATING ODDS .....\n";

system("pause");

system("CLS");

// The Math

// Scoring System:

// Average Passing Yards = +0.5 Points Per Yard

// Average Passing Yards = +1.0 Points Per Yard

// Average Yards Against = -1.5 Points per Yard

// Average Sacks = +5.0 Points Per Sack

// Average Interceptions = +5.0 Points Per Interception

// League Rank = (1) 50.0 Points; (2) 40.0 Points; (3) 30.0 Points; (4) 20.0 Points ...

// Win / Lose Streak = (3) +/- 20.0 Points; (4) +/- 25.0 Points; (5) +/- 30.0 Points ...

//

// Sport Book odds : If dTeam1line < dTeam2line then dTeam1 + 10.0 Points

// If dTeam2line < dTeam1line then dTeam1 - 10.0 Points

//

// Comparing The Teams: If dTeam1 > dTeam2 then dTeam1 Wins

// If dTeam2 > dTeam1 then dTeam2 Wins

//

// Calculate % for each team: dTeam1 + dTeam2 = dTotal

// dTotal / dTeam1 = dTeam1p

// dTotal / dTeam2 = dTeam2p

//

// Display Winning Team and Percantage.

// Calculating Odds.

// Team 1

temp = iTeam1apy * Dapy;

dTeam1 = temp + dTeam1;

temp = iTeam1ary * Dary;

dTeam1 = temp + dTeam1;

temp = iTeam1aya * Daya;

dTeam1 = temp + dTeam1;

temp = dTeam1as * Das;

dTeam1 = temp + dTeam1;

temp = dTeam1ai * Dai;

dTeam1 = temp + dTeam1;

//Team 2

temp = iTeam2apy * Dapy;

dTeam2 = temp + dTeam2;

temp = iTeam2ary * Dary;

dTeam2 = temp + dTeam2;

temp = iTeam2aya * Daya;

dTeam2 = temp + dTeam2;

temp = dTeam2as * Das;

dTeam2 = temp + dTeam2;

temp = dTeam2ai * Dai;

dTeam2 = temp + dTeam2;

//If Statments

//League Position

//Team 1

if (iTeam1lp == 1)

dTeam1 = dTeam1 + 50;

if (iTeam1lp == 2)

dTeam1 = dTeam1 + 40;

if (iTeam1lp == 3)

dTeam1 = dTeam1 + 30;

if (iTeam1lp == 4)

dTeam1 = dTeam1 + 20;

if (iTeam1lp == 5)

dTeam1 = dTeam1 + 10;

//Team 2

if (iTeam2lp == 1)

dTeam2 = dTeam2 + 50;

if (iTeam2lp == 2)

dTeam2 = dTeam2 + 40;

if (iTeam2lp == 3)

dTeam2 = dTeam2 + 30;

if (iTeam2lp == 4)

dTeam2 = dTeam2 + 20;

if (iTeam2lp == 5)

dTeam2 = dTeam2 + 10;

// Win/Lose Streak if statments

// Team 1

if (iTeam1wl == 3)

dTeam1 = dTeam1 + 20;

if (iTeam1wl == 4)

dTeam1 = dTeam1 + 25;

if (iTeam1wl >= 5)

dTeam1 = dTeam1 + 30;

if (iTeam1wl == -3)

dTeam1 = dTeam1 - 20;

if (iTeam1wl == -4)

dTeam1 = dTeam1 - 25;

if (iTeam1wl >= -5)

dTeam1 = dTeam1 - 30;

//Team 2 If Statments

if (iTeam2wl == 3)

dTeam2 = dTeam2 + 20;

if (iTeam2wl == 4)

dTeam2 = dTeam2 + 25;

if (iTeam2wl >= 5)

dTeam2 = dTeam2 + 30;

if (iTeam2wl == -3)

dTeam2 = dTeam2 - 20;

if (iTeam2wl == -4)

dTeam2 = dTeam2 - 25;

if (iTeam2wl >= -5)

dTeam2 = dTeam2 - 30;

// Sport Book Lines. If statments

if (dTeam1line > dTeam2line)

dTeam1 = dTeam1 + 10;

if (dTeam2line > dTeam1line)

dTeam2 = dTeam2 + 10;

// Final

cout << "Generated Score: \n";

cout << "Home Team: " << dTeam1 << "Away Team: " << dTeam2;

system("pause");

//The End

system("pause");

return EXIT_SUCCESS;

}

It compiles & runs, therefore something is wrong with the math. If you read the comment area of the code I try to explain the "Scoring System". When I ran the application to test it, I entered the data in a way that Team 1 would obviously generate a higher score, but it did not. I haven't coded in years and I'm under the impression they're many, many mistakes in this code even though it compiled. You are going to ask me "What's the ouput it's giving you and what are you expecting it to output? " ... Well it's a little hard to explain but if you look at the comment area of the code, the scoring system to be more precise, run the application and test the math, you'll notice it's not working.

Also... Using double temp; as a variable to store temporary data, does that make sence?

Please, I'm looking forward to your help and suggestions.

Kind Regards

-Mat P.