Hello all, I am a noob in the process of learning C++ and so far things are going good. However I wrote a pretty simple Baseball statistics program from out of my book today and it keeps compiling with errors but I can't understand what is wrong with my code. If anyone would be willing to look at my code and give me a hint as to what I am missing it would be greatly appreciated.
// BaseballStats.cpp : main project file.
#include "stdafx.h"
#include<iostream>
usingnamespace std;
int main()
{
int lowAtBats;
int highAtBats;
int atBats;
BaseballPlayer onePlayer;
cout << "Please enter the baseball players number ";
cin >> onePlayer.playerNumber;
cout << "Now enter the number of hits for the player #" << onePlayer.playerNumber << " ";
cin >> onePlayer.numberOfHits;
cout << "\nNext enter the low number of at bats for which you want statistics ";
cin >> lowAtBats;
while(lowAtBats < onePlayer.numberOfHits)
{
cout << "***Player had " << onePlayer.numberOfHits << " hits, so you must enter that number or more" << endl;
cout << " Please reenter the low number of at bats ";
cin >> lowAtBats;
}
cout << "\nEnter the most at bats for which you want statistics ";
cin >> highAtBats;
while(highAtBats < lowAtBats)
{
cout<<"***You entered " << lowAtBats <<
" for the low number of at bats" << endl << " so you must enter that number or more" << endl;
cout << " Please reenter a number for most at bats ";
cin >> highAtBats;
}
cout<<"\nFor player #" << onePlayer.playerNumber << endl;
atBats = lowAtBats;
while(atBats <= highAtBats)
{
cout<< onePlayer.numberOfHits << " hits in " << atBats <<
" at bats is an average of " <<
(onePlayer.numberOfHits * 1.0) / atBats << endl;
++atBats;
}
system("pause");
return 0;
}
Okay well, I probably just need to finish reading this chapter I am in and then I will go back and see if I can figure out what I am doing wrong. Thanks for the suggestions. I will come back here if I am still stuck later.
Peace out.