Does Anybody know how to use C++ to get information from a database? I have this assignment due but , I do no know to incorporate a database into my program. My program is to allow a user to choose from NFL football teams,when the user picks the team , they will see that teams 2004 draft picks.Here is how I have started without using a database.
function file:
#include <fstream> //for file I/O *
#include <string>
#include <iostream> //for cin and cout *
#include "2004draft.h"
#include <math.h>
#include <stdlib.h> //for exit() *
using namespace std;
const double pi = 3.14159;
//**********************************************************************************************
//**********************************************************************************************
void Draft::intro()
{
cout<<"\n\n\t ********* 2004 NFL DRAFT PROGRAM *********\n\n"
<<"\t(NFL teams only - one of each team)\n"
<<"\tYou will be given six choices.\n"
<<"\tPick the team that you are interested in,\n"
<<"\tbut first, ";
}
void Draft::getUsername()
{
cout<<"\n\n Please enter your name: ";
getline(cin,userName);
}
void Draft::getClassname()
{
cout<<" Enter class name: ";
cin>>className;
}
void Draft::getDate()
{
cout<<" Enter day: ";
cin>>day;
cout<<" Enter month: ";
cin>>month;
cout<<" Enter year: ";
cin>>year;
}
//************************************************************************************************
//************************************************************************************************
void Draft::getDBinfo()
{
cout<<"\n Round 1 (17): LB D.J. Williams,Miami:"<<endl;
cout<<"\n Round 2 (41): RB Tatum Bell ,Oklahoma State:"<<endl;
cout<<"\n Round 2 (54): WR Darius Watts,Marshall :"<<endl;
cout<<"\n Round 3 (85): CB Jeremy LeSueur,Michigan :"<<endl;
cout<<"\n Round 5 (152): CB Jeff Shoate,San Diego State :"<<endl;
cout<<"\n Round 6 (171): WR Triandos Luke,Alabama :"<<endl;
cout<<"\n Round 6 (190): C Josh Sewell,Nebraska :"<<endl;
cout<<"\n Round 7 (225): QB Matt Mauck,Louisiana State:"<<endl;
cout<<"\n Round 7 (247): RB Brandon Miree ,Pittsburgh :"<<endl;
cout<<"\n Round 7 (250): QB Bradlee Van Pelt,Colorado State:"<<endl;
}
//************************************************************************************************
//************************************************************************************************
void Draft::getMVinfo()
{
cout<<"\n Round 1 (20) : Kenechi Udeze DE USC (from Miami) "<<endl;
cout<<"\n Round 2 (48): Dontarrious Thomas OLB Auburn (from New Orleans)" <<endl;
cout<<"\n Round 3 (88): Darrion Scott DE Ohio St. (from Baltimore) "<<endl;
cout<<"\n Round 4 (115) Nat Dorsey OT Georgia Tech "<<endl;
cout<<"\n Round 4 (119) Mewelde Moore RB Tulane (from Miami) "<<endl;
cout<<"\n Round 5 (155) Rod Davis MLB Southern Miss (from Baltimore) "<<endl;
cout<<"\n Round 6 (184) Deandre' Eiland S South Carolina "<<endl;
cout<<"\n Round 7 (220) Jeff Dugan TE Maryland"<<endl;
}
//************************************************************************************************
//************************************************************************************************
void Draft::getDCinfo()
{
cout<<"\n Round 2 (43) Julius Jones RB Notre Dame (from Buffalo) "<<endl;
cout<<"\n Round 2 (52) Jacob Rogers OT USC "<<endl;
cout<<"\n Round 3 (83) Stephen Peterman OG LSU " <<endl;
cout<<"\n Round 4 (121) Bruce Thornton CB Georgia"<<endl;
cout<<"\n Round 5 (144) Sean Ryan TE Boston College (from Buffalo)" <<endl;
cout<<"\n Round 7 (205) Nate Jones CB Rutgers (from Oakland)" <<endl;
cout<<"\n Round 7 (216) Patrick Crayton WR NW Oklahoma St. (from Tampa Bay)"<<endl;
cout<<"\n Round 7 (223) Jacques Reeves CB Purdue (from Dallas via Oakland)"<<endl;
}
//************************************************************************************************
//************************************************************************************************
void Draft::getACinfo()
{
cout<<"\n Round 1 (3) Larry Fitzgerald WR Pittsburgh"<<endl;
cout<<"\n Round 2 (33) Karlos Dansby OLB Auburn" <<endl;
cout<<"\n Round 3 (64) Darnell Dockett DT Florida St."<<endl;
cout<<"\n Round 4 (100) Alex Stepanovich C Ohio St. "<<endl;
cout<<"\n Round 5 (135) Antonio Smith DE Oklahoma St. "<<endl;
cout<<"\n Round 6 (167) Nick Leckey C Kansas St. "<<endl;
cout<<"\n Round 7 (202) John Navarre QB Michigan "<<endl;
}
//************************************************************************************************
//***********************************************************************************************
void Draft::getDLinfo()
{
cout<<"\n Round 1 (7) Roy Williams WR Texas (from Cleveland)"<<endl;
cout<<"\n Round 1 (30) Kevin Jones RB Virginia Tech (from Kansas City)"<<endl;
cout<<"\n Round 2 (37) Teddy Lehman OLB Oklahoma (from Cleveland)"<<endl;
cout<<"\n Round 3 (73) Keith Smith CB McNeese St." <<endl;
cout<<"\n Round 5 (140) Alex Lewis OLB Wisconsin "<<endl;
cout<<"\n Round 6 (172) Kelly Butler OT Purdue "<<endl;
}
//*************************************************************************************************
//*************************************************************************************************
void Draft::getSCinfo()
{
cout<<"\n Round 1 (1) Eli Manning QB Mississippi traded to NY Giants "<<endl;
cout<<"\n Round 2 (35) Igor Olshansky DT Oregon "<<endl;
cout<<"\n Round 3 (65) Nate Kaeding K Iowa (from NY Giants)"<<endl;
cout<<"\n Round 3 (66) Nick Hardwick C Purdue "<<endl;
cout<<"\n Round 4 (98) Shaun Phillips DE Purdue "<<endl;
cout<<"\n Round 5 (133) Dave Ball DE UCLA "<<endl;
cout<<"\n Round 5 (154) Michael Turner RB Northern Illinois (from Miami)"<<endl;
cout<<"\n Round 6 (169) Ryan Krause WR Nebraska (Omaha) "<<endl;
cout<<"\n Round 7 (204) Ryon Bingham DT Nebraska"<<endl;
cout<<"\n Round 7 (209) Shane Olivea OT Ohio St. (from Atlanta)"<<endl;
cout<<"\n Round 7 (254) Carlos Joseph OT Miami (Fl) (Compensatory) "<<endl;
}
//************************************************************************************************
//************************************************************************************************
void Draft::getGBinfo()
{
cout<<"\n Round 1 (25) Ahmad Carroll CB Arkansas "<<endl;
cout<<"\n Round 3 (70) Joey Thomas CB Montana St. (from Jacksonville) "<<endl;
cout<<"\n Round 3 (72) Donnell WashingtonDT Clemson(from Washington via Jacksonville)"<<endl;
cout<<"\n Round 3 (87) B.J. Sander P Ohio St (from Miami)"<<endl;
cout<<"\n Round 6 (179) Corey Williams DT Arkansas St.(from San Francisco)"<<endl;
cout<<"\n Round 7 50 (251) Scott Wells C Tennessee (Compensatory)"<<endl;
}
//*************************************************************************************************
//************************************************************************************************
//void Draft::getAFinfo()
//{
//}
//*************************************************************************************************
//************************************************************************************************
void Draft::outputName()
{
cout<<"\n\n 2004 nfl team draft locator "<<userName<<"."<<endl;}
void Draft::outputCourseNum()
{
cout<<" I hope you enjoyed the "<<className<<" class."<<endl;}
void Draft::outputDate()
{
cout<<" You logged in on "<<day<<" "<<month<<" "<<year<<"."<<endl<<endl;}
file to display
#include<iostream>
#include "2004draft.h"
#include<math.h>
using namespace std;
void main()
{
Draft findTeam;
findTeam.intro();
findTeam.getUsername();
findTeam.getClassname();
findTeam.getDate();
findTeam.outputName();
findTeam.outputCourseNum();
findTeam.outputDate();
cin.clear(); //This keeps variables from
cin.ignore(100,'\n'); // getting into 'choice',
// allows switch to work.
int choice;
do{
cout<<"\n\n Enter choice number:\t1 - Denver Broncos\n"<<
"\t\t\t2 - Minnisota Vikings \n"<<
"\t\t\t3 - Dallas Cowboys\n"<<
"\t\t\t4 - Arizona Cardinals \n"<<
"\t\t\t5 - Detroit Lions \n"<<
"\t\t\t6 - San Diego Chargers \n"<<
"\t\t\t7 - Green Bay Packers \n"<<
"\t\tor any other entry to quit: ";
cin>>choice;
switch (choice)
{
case 1:
findTeam.getDBinfo();
//findTeam.calcRC();
break;
case 2:
findTeam.getMVinfo();
//findTeam.calcRL();
break;
case 3:
findTeam.getDCinfo();
//findTeam.calcRLC();
break;
case 4:
findTeam.getACinfo();
//findTeam.calcParaRC();
break;
case 5:
findTeam.getDLinfo();
//findTeam.calcParaRL();
break;
case 6:
findTeam.getSCinfo();
//findTeam.calcParaRLC();
break;
case 7:
findTeam.getGBinfo();
}
}while(choice == 1 || choice == 2 || choice == 3 || choice == 4 || choice == 5 || choice == 6 || choice ==7);
}
IF anybody has some useful info I would appreciate it.