baseball stats program help plz


Hi cplusplus members I need help with my assignment I'm not understanding what I'm doing wrong my program wont run because of a error on line 52 column 1 expected error unqualified id before '{' token.

My assignment is to read in the id number and the won lost record of a baseball team.It will compute various things about the team, and it will print everything out. Then it will repeat the process for a new team, over and over again, until the entire set of data has been taken care of. At the end, it will print the number of teams.

Here is a complete set of output for a typical team:

team 4563 4 wins 12 losses total number of games played is 16 9 games remaining the winning average is 0.2500 number of games remaining is greater than or equal to number won number of games remaining is not greater than number lost
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
//The program will compute baseball statistics

#include <iostream>
#include <cmath>

using namespace std;

int main()
{
int id, wins, losses, nd, totalgames, gamesremaining, wiptotal, gp=0;
double winavg;

cout << "Enter team's' id: ";
cout << "To stop, enter a negative value as the teams id number> ";
cin >> id;
while (id>=0) {
cout << "Enter number of wins: ";
cin >> wins;
cout << "Enter number of losses: ";
cin >> losses;
cout << "Enter number of no decisions: ";
cin >> nd;
cout << "Enter teams winning average: ";
cin >> winavg;

gp++;


cout << "team " << id << endl;
cout << wins << "wins" << losses << "losses" << nd << "no decision" << endl;
}

totalgames=wins + losses + nd;

cout << "Total number of games played is: " << totalgames << endl;

gamesremaining=25-totalgames;

if (totalgames==25)
cout << "The teams season is finisheed" << endl;

else
cout << "Print gamesremaining" << endl;

cout << "The number of games remaining is: " << gamesremaining << endl;

return 0;
}

// The program will compute the teams winning average and wiptotal

{
		
double winavg;

cout.setf (ios::fixed, ios::floatfield);
cout.precision (4);

winavg=wins/totalgames;

cout << "Teams winning average is: " << winavg << endl;


if (nd>=wins)
cout << "Number of games with no decision is greater than or equal to number of wins" << endl;

else (nd<losses)
cout <<"Number of games with no decision is not greater than number of losses" << endl;


wiptotal=wins + nd - (2 * losses);

cout << "The wip total is: " << wiptotal << endl;


cout << "We processed " << gp << "teams << endl;"
return 0;
} 
First of all, you have a very rude habit of erasing your posts after someone has answered to you. Nobody, who browses those threads later, will know what the discussion was about. Why would anyone, who wants to help everyone with their answers, answer to you when they know that you will render the answer useless?

Second, the use of code tags is good, but you should use consistent and informative indentation too. That really helps to see the logical structure of your program.


Third. What do you have before line 52? That is where the compiler points to. What do you have there? What do you think that you have there?
sorry i had to delete my previous post because it was entirly wrong and didnt want anyone to get the wrong idea on how to do their assignment. as for line everything before line 52 its where the user enter the information for their team using cin and after that on line 52 its where i take the user given data to calculate the winning average and winning percentage total
Here is a simpler, indented code that has the same error before line 10.
1
2
3
4
5
6
7
8
9
10
11
12
13
int main()
{
  int wins;
  return 0;
}




{
  double avg;
  return 0;
}

What is fundamentally wrong with the syntax?


PS. Nobody here gets wrong ideas about erroneus code. (And if they do, they do deserve it.) However, everyone can still learn from mistakes. In fact, seeing errors can teach you more than seeing only flawless programs.
Topic archived. No new replies allowed.