Answer» hi i have this program but cannot find problem. it suppose to enter the points of a SOCCER team & where they PLAYED.then it MUST CALCULATE the total points of the games played at home by the team & the points of the opponents.As well as the points played away from home by team & opponents.but it only reads in the last entry. i think my void functions is wrong bt dnt KNW wat to change it to!!! please help!!! please //assignment 2 Question 5 #include using namespace std; int nr_matches = 9;
void inputAndValidated (int & pointsForp,int & pointsAgainstp, char & wherep) { for(int i=0; i< 4; i++) { do { cout<<"Where was the match played? "; cin>> wherep; cout< }while((wherep != 'H' ) &&(wherep != 'A')); cout<<"Enter the number of points scored by the Lions : "; cin>> pointsForp; cout<<"Enter the number of points scored by the opponents: "; cin>> pointsAgainstp; } } void updateTotalsHome (int teamsPoint,int opponentsPoints, int & teamsTotal ,int & opponentsTotal) { teamsTotal= 0; opponentsTotal=0; teamsTotal += teamsPoint; opponentsTotal += opponentsPoints;
}
void updateTotalAway(int teamsPointA,int opponentsPointsA,int & teamsTotalA ,int & opponentsTotalA) { teamsTotalA=0; opponentsTotalA=0; teamsTotalA += teamsPointA; opponentsTotalA += opponentsPointsA;
int main() { int pointsFor,pointsAgainst; int totalForHome,totalAgainstHome,totalForAway,totalAgainstAway; int nrHome,nrAway; char where; // initialise totals totalForHome=0; totalAgainstHome=0; totalForAway= 0; totalAgainstAway=0; nrHome=0; nrAway=0; inputAndValidated(pointsFor,pointsAgainst,where); if(where =='H') { nrHome++; updateTotalsHome(pointsFor,pointsAgainst, totalForHome,totalAgainstHome); } else { nrAway++; updateTotalAway(pointsFor,pointsAgainst,totalForAway,totalAgainstAway); } cout<<"The total at this point is: "< cout<<"Played at home: "< cout<<"Total points scored by the team "< cout<<"Total points scored by the opponents "< cout< cout<<"Played away from home: "< cout<<"Total points scored by the team "< cout<<"Total points scored by the opponents "< cout< return 0 ; }
|